Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
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 | |
|
|
![]() |
||||
Thread | Forum | |||
word opens access in mail merge. Access is already opened.=twice | Mailmerge | |||
Access Word Mail Merge help | Mailmerge | |||
Mail Merge using Word XP and Access XP | Mailmerge | |||
Word Mail Merge With Access | Mailmerge | |||
Mail merge from Access to Word | Mailmerge |