Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Decembersonata Decembersonata is offline
external usenet poster
 
Posts: 3
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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Decembersonata Decembersonata is offline
external usenet poster
 
Posts: 3
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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Decembersonata Decembersonata is offline
external usenet poster
 
Posts: 3
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?



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
word opens access in mail merge. Access is already opened.=twice Sherri Mailmerge 1 February 11th 06 05:59 PM
Access Word Mail Merge help [email protected] Mailmerge 1 December 20th 05 06:50 PM
Mail Merge using Word XP and Access XP Tom Sawyer Mailmerge 2 August 3rd 05 05:38 AM
Word Mail Merge With Access Connie Mailmerge 1 June 2nd 05 07:22 PM
Mail merge from Access to Word PatAce Mailmerge 5 March 30th 05 11:03 PM


All times are GMT +1. The time now is 02:15 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"