A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access to Word Mail Merge



 
 
Thread Tools Display Modes
  #1  
Old August 19th, 2009, 11:29 PM posted to microsoft.public.word.mailmerge.fields
Decembersonata
external usenet poster
 
Posts: 15
Default Access to Word Mail Merge

I have an Access db that currently is the data source for a mail merged Word
doc. The user presses a button on the Access form to take them directly to
the mail merged document, here is the code:

Private Sub Command125_Click()
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
appWd.Documents.Open
FileName:="I:\groups\PAYROLL\Payroll_Renwals\RENEW-LETTER-sef.docx"
End Sub

The Word doc opens just fine, however it does not automatically link to the
saved data source (in this case a table from the database), so the user has
to manually select the data source in order to update the information. Is
there a way to link out to this Word doc from Access, opening the document
with the data source in tact?
  #2  
Old August 20th, 2009, 01:38 AM posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default Access to Word Mail Merge

Was the document saved with the data source attached to it?

The following is cobbled up from the Word VBA help file to show how to
attach the data source to the document if all else fails.

Private Sub Command125_Click()
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
Set docnew =
appWd.Documents.Open("I:\groups\PAYROLL\Payroll_Re nwals\RENEW-LETTER-sef.docx")
With docNew.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource _
Name:="C:\Program Files\Microsoft Office" & _
"\Office\Samples\Northwind.mdb", _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE Orders"
End With
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Decembersonata" wrote in message
news
I have an Access db that currently is the data source for a mail merged
Word
doc. The user presses a button on the Access form to take them directly
to
the mail merged document, here is the code:

Private Sub Command125_Click()
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
appWd.Documents.Open
FileName:="I:\groups\PAYROLL\Payroll_Renwals\RENEW-LETTER-sef.docx"
End Sub

The Word doc opens just fine, however it does not automatically link to
the
saved data source (in this case a table from the database), so the user
has
to manually select the data source in order to update the information. Is
there a way to link out to this Word doc from Access, opening the document
with the data source in tact?


  #3  
Old August 20th, 2009, 05:47 PM posted to microsoft.public.word.mailmerge.fields
Decembersonata
external usenet poster
 
Posts: 15
Default Access to Word Mail Merge

So I used the code as follows:Private Sub Command125_Click()

Set appWd = CreateObject("Word.Application")
appWd.Visible = True
Set docnew =
appWd.Documents.Open("I:\groups\PAYROLL\Payroll_Re nwals\RENEW-LETTER-sef.docx")
With docnew.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource _

Name:="I:\groups\dar\GPROC\PAYROLL\Payroll_The_Hea ly\TheHealy.accdb", _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="aa_renewals"
End With


End Sub

However, it then gives me an error message that says: "Run-time error
'5174': This file could not be found (I:groups...)

I checked the path and it is accurate and will open with other code. Am I
missing something in my translation of the code?

"Doug Robbins - Word MVP" wrote:

Was the document saved with the data source attached to it?

The following is cobbled up from the Word VBA help file to show how to
attach the data source to the document if all else fails.

Private Sub Command125_Click()
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
Set docnew =
appWd.Documents.Open("I:\groups\PAYROLL\Payroll_Re nwals\RENEW-LETTER-sef.docx")
With docNew.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource _
Name:="C:\Program Files\Microsoft Office" & _
"\Office\Samples\Northwind.mdb", _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE Orders"
End With
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Decembersonata" wrote in message
news
I have an Access db that currently is the data source for a mail merged
Word
doc. The user presses a button on the Access form to take them directly
to
the mail merged document, here is the code:

Private Sub Command125_Click()
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
appWd.Documents.Open
FileName:="I:\groups\PAYROLL\Payroll_Renwals\RENEW-LETTER-sef.docx"
End Sub

The Word doc opens just fine, however it does not automatically link to
the
saved data source (in this case a table from the database), so the user
has
to manually select the data source in order to update the information. Is
there a way to link out to this Word doc from Access, opening the document
with the data source in tact?



  #4  
Old August 20th, 2009, 07:49 PM posted to microsoft.public.word.mailmerge.fields
Decembersonata
external usenet poster
 
Posts: 15
Default Access to Word Mail Merge

I figured it out. Instead of trying to open the Word document containing the
mail merge, I instead coding in to have it follow a hyperlink. When it
follows the hyperlink the data source remains in tact. The code, for anyone
interested, is:

Private Sub Command125_Click()
Dim ObjectApp As Object
Dim strLinkUrl As String
Dim strPath As String

Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Application.WindowState = wdWindowStateMaximize
objApp.Application.Activate


' for a subdirectory located in the same directory
' as the database:
objApp.Visible = True
objApp.Application.Activate

strPath = Access.Application.CurrentProject.Path & "\"

strLinkUrl = strPath & "RENEW-LETTER-sef.docx"

Me.Command125.HyperlinkAddress = strLinkUrl

End Sub

"Doug Robbins - Word MVP" wrote:

Was the document saved with the data source attached to it?

The following is cobbled up from the Word VBA help file to show how to
attach the data source to the document if all else fails.

Private Sub Command125_Click()
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
Set docnew =
appWd.Documents.Open("I:\groups\PAYROLL\Payroll_Re nwals\RENEW-LETTER-sef.docx")
With docNew.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource _
Name:="C:\Program Files\Microsoft Office" & _
"\Office\Samples\Northwind.mdb", _
LinkToSource:=True, AddToRecentFiles:=False, _
Connection:="TABLE Orders"
End With
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Decembersonata" wrote in message
news
I have an Access db that currently is the data source for a mail merged
Word
doc. The user presses a button on the Access form to take them directly
to
the mail merged document, here is the code:

Private Sub Command125_Click()
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
appWd.Documents.Open
FileName:="I:\groups\PAYROLL\Payroll_Renwals\RENEW-LETTER-sef.docx"
End Sub

The Word doc opens just fine, however it does not automatically link to
the
saved data source (in this case a table from the database), so the user
has
to manually select the data source in order to update the information. Is
there a way to link out to this Word doc from Access, opening the document
with the data source in tact?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.