W
Wilson Pye
Hi,
I am trying to automate mailabels.
So far the program runs as planned up to
" .ActiveDocument.MailMerge.Destination=wdSendToNewDocument"
and I get an error message from Word.
"OLE IDispatch exception code 0 from Microsoft Word
Requested object is not available".
Can my OpenDataSource be an issue? I am using a tab delimited txt file?
Any help greatly appreciated
Wilson
WITH oWord
.VISIBLE=.T.
.SELECTION.InsertParagraphAfter
.ActiveDocument.MailMerge.EditMainDocument
.SELECTION.InsertParagraphAfter
.ActiveDocument.MailMerge.FIELDS.ADD;
(oWord.SELECTION.RANGE,"purfirstla")
.SELECTION.InsertParagraphAfter
.SELECTION.MoveDown
.ActiveDocument.MailMerge.FIELDS.ADD;
(oWord.SELECTION.RANGE,"purhmstree")
.SELECTION.InsertParagraphAfter
.SELECTION.MoveDown
.ActiveDocument.MailMerge.FIELDS.ADD;
(oWord.SELECTION.RANGE,"purhmaddre")
oAutoText="Word.AutoTextEntry"
oAutoText=oWord.NormalTemplate.AutoTextEntries.ADD("MyLabelLayout",
oDocument.Content)
oDocument.Content.DELETE
..ActiveDocument.MailMerge.OpenDataSource("c:\tournakit\DATA\templabels.txt")
oWord.MailingLabel.CreateNewDocument("5160","","MyLabelLayout",wdPrinterManu
alFeed)
.ActiveDocument.MailMerge.Destination=wdSendToNewDocument
.ActiveDocument.MailMerge.Execute()
oAutoText.DELETE
ENDWITH
I am trying to automate mailabels.
So far the program runs as planned up to
" .ActiveDocument.MailMerge.Destination=wdSendToNewDocument"
and I get an error message from Word.
"OLE IDispatch exception code 0 from Microsoft Word
Requested object is not available".
Can my OpenDataSource be an issue? I am using a tab delimited txt file?
Any help greatly appreciated
Wilson
WITH oWord
.VISIBLE=.T.
.SELECTION.InsertParagraphAfter
.ActiveDocument.MailMerge.EditMainDocument
.SELECTION.InsertParagraphAfter
.ActiveDocument.MailMerge.FIELDS.ADD;
(oWord.SELECTION.RANGE,"purfirstla")
.SELECTION.InsertParagraphAfter
.SELECTION.MoveDown
.ActiveDocument.MailMerge.FIELDS.ADD;
(oWord.SELECTION.RANGE,"purhmstree")
.SELECTION.InsertParagraphAfter
.SELECTION.MoveDown
.ActiveDocument.MailMerge.FIELDS.ADD;
(oWord.SELECTION.RANGE,"purhmaddre")
oAutoText="Word.AutoTextEntry"
oAutoText=oWord.NormalTemplate.AutoTextEntries.ADD("MyLabelLayout",
oDocument.Content)
oDocument.Content.DELETE
..ActiveDocument.MailMerge.OpenDataSource("c:\tournakit\DATA\templabels.txt")
oWord.MailingLabel.CreateNewDocument("5160","","MyLabelLayout",wdPrinterManu
alFeed)
.ActiveDocument.MailMerge.Destination=wdSendToNewDocument
.ActiveDocument.MailMerge.Execute()
oAutoText.DELETE
ENDWITH