Error running MS Word 2003 Mail Merge Macro from Progress

davjoh

New Member
I receive this error message when running my progress code - "Microsoft Visual Basic Run-Time Error '5852': Requested Object is Not Available"...when I choose Debug it indicates ".Destination = wdSendToNewDocument" is the problem. The macro runs without errors when executed from Word.

The macro opens C:\edm0034.doc then uses C:\jobprwk.xls for Mail Merge then Prints the merged document and closes the files. I have attached those 2 files to help with troubleshooting.

/* MY PROGRESS CODE */
def var word as com-handle.
create "word.application" word.
word:Visible = false.
word:DisplayAlerts = false.
word:run("'normal.dot'!solar_hc").
pause 15 message "HardCard Printing...Please Wait!".
word:quit().
release object word.

/* MY WORD MACRO */
Sub Solar_HC()
ChangeFileOpenDirectory "C:\"
Documents.Open FileName:="edm0034.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 = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
ActiveDocument.PrintOut
ActiveWindow.Close
ActiveWindow.Close
End Sub


 

Attachments

  • macro.zip
    38.5 KB · Views: 7

Rahim

New Member
Yes.There a error occured in ms word 2003.My self try my best.I'm not yet try to merge in word 2007.Most probably we are recomend the MS word 2000.

when we open the data source from MS word 2003.in the word task bar given some data conversion message.i think that is thing and when use the cording we cannot convert the internel components.

If any one can to solve the problem.that is better to us and more credits goes to him.
 
Top