Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
AndrewC
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default 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

Posting Rules

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mailmerge numeric field format Darryl Mailmerge 1 April 7th 06 06:01 AM
Mailmerge printing query Jim Nicholls Mailmerge 1 August 4th 05 02:53 PM
Field code error when printing document Olga Microsoft Word Help 1 January 25th 05 06:59 PM
Missing Lines when printing from a mailmerge Martin Short Mailmerge 0 December 22nd 04 06:05 PM
Macro to Find/Replace (with MailMerge Field)? aiyou Mailmerge 1 December 8th 04 07:39 AM


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

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"