Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
MailMerge Through VBA Printing Actual Field Names NOT Field Values
Hello.
I hopefully have a quick question on VBA. I am automating a merge process. However I created a few documents that link are already setup and linked to their data sources. I also have a blank document that I am using to run a VBA form. When the document is open the VBA form is open. One function of the form is to print all the documents in a specific directory - these are the documents previously linked to a specific data source file. All the VBA code must do is open the document and print the merged data source. I'd like it to merge to a new document and then print. Any dialogue boxes should be suppressed and the document should be closed after it is sent to the print queue. Now the problem is that when I open the document what commands do I issue since the documents I am opening are already linked to the data source. If I immediately print, I get the field names and not a merge w/ the actual data. The following does NOT work: Documents.Open FileName:=sFilePath & sNextFile, ConfirmConversions:=False, AddToRecentFiles:=False, Visible:=True 'ActiveDocument.MailMerge.MainDocumentType = wdFormLetters ActiveDocument.MailMerge.Destination = wdSendToNewDocument ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False ' this line even creates a run-time error because the object can not be found! 'ActiveDocument.MailMerge.Execute Thank you in advance! Andy |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
MailMerge Through VBA Printing Actual Field Names NOT Field Values
The "object does not exist" error is almost certainly generated because the
Word document is not connected to a datasource. You will probably need to apply the following KB article: "Opening This Will Run the Following SQL Command" Message When You Open a Word Document" at http://support.microsoft.com?kbid=825765 Peter Jamieson "AndrewC" wrote in message oups.com... Hello. I hopefully have a quick question on VBA. I am automating a merge process. However I created a few documents that link are already setup and linked to their data sources. I also have a blank document that I am using to run a VBA form. When the document is open the VBA form is open. One function of the form is to print all the documents in a specific directory - these are the documents previously linked to a specific data source file. All the VBA code must do is open the document and print the merged data source. I'd like it to merge to a new document and then print. Any dialogue boxes should be suppressed and the document should be closed after it is sent to the print queue. Now the problem is that when I open the document what commands do I issue since the documents I am opening are already linked to the data source. If I immediately print, I get the field names and not a merge w/ the actual data. The following does NOT work: Documents.Open FileName:=sFilePath & sNextFile, ConfirmConversions:=False, AddToRecentFiles:=False, Visible:=True 'ActiveDocument.MailMerge.MainDocumentType = wdFormLetters ActiveDocument.MailMerge.Destination = wdSendToNewDocument ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False ' this line even creates a run-time error because the object can not be found! 'ActiveDocument.MailMerge.Execute Thank you in advance! Andy |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Mailmerge numeric field format | Mailmerge | |||
Mailmerge printing query | Mailmerge | |||
Field code error when printing document | Microsoft Word Help | |||
Missing Lines when printing from a mailmerge | Mailmerge | |||
Macro to Find/Replace (with MailMerge Field)? | Mailmerge |