Word Macros and Mail Merge

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

doncard

Thread Starter
Joined
Aug 24, 2004
Messages
4
I am running MS Office 2003 and am trying to create a Word macro to open a main document with an attached data source, execute a merge and save the resulting document. I just get an error message: " Run time error 5852, Requester object is not available". I have been able to create a macro to execute a merge and save the resulting document on a main document that I open normally but not when opened by the macro itself. What am I doing wrong?
 

doncard

Thread Starter
Joined
Aug 24, 2004
Messages
4
Gave it a try. Following directions was tough as I run Word 2003 and the VBE is quite different from 2000. I didn't have any luck...the merge did not run. I tried the mailmerge document with data set on another computer running Word 2000. I followed the directions to the letter. Still no luck...same as before. I am using a text based data set, could this be the problem?
 

Anne Troy

Anne
Joined
Feb 14, 1999
Messages
11,746
The VBE in 2003 is NOT different from 2000 at all. It sounds like you have different settings tho.

Go to View and make sure you're viewing the project explorer and the properties windows.
 

doncard

Thread Starter
Joined
Aug 24, 2004
Messages
4
Here is the code. The intention is to open a main doc with attached data, execute a merge, save the merged doc and close.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/26/2004 by Don
'
Documents.Open FileName:="AnnRev1.doc", ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
.LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord
End With
.Execute Pause:=False
End With
ChangeFileOpenDirectory _
"C:\Documents and Settings\don.DMR-HOMELTDCARD\My Documents\WIP\MergeDocs\"
ActiveDocument.SaveAs FileName:="AnnRev1.doc", FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveDocument.Close
ActiveDocument.Close
End Sub

It gets hungup at '.Destination = wdSendToNewDocument'.
 

doncard

Thread Starter
Joined
Aug 24, 2004
Messages
4
Yep, I was in the wrong view. I did the 'Automating Mail Merge' and it did run but not quite automatically. The SQL dialogue box comes up and requires input before the merge. This sounds picky, but I eventually would like to automate the opening, merging and saving of a dozen documents in one fell swoop.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top