Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / April 2006

Tip: Looking for answers? Try searching our database.

MailMerge Through VBA Printing Actual Field Names NOT Field Values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AndrewC - 23 Apr 2006 07:32 GMT
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
Peter Jamieson - 23 Apr 2006 08:07 GMT
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

> Hello.
>
[quoted text clipped - 33 lines]
>
> Andy
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.