Error message help? "Requested object is not available"

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
 
C

Cindy M -WordMVP-

Hi Wilson,
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?
Hard to say, with only this information, what the exact problem might
be... My first inclination would be to ask: why are you using
ActiveDocument rather than an object variable referring to the document?

The second: are you certain wdSendToNewDocument is being recognized
correctly? Wouldn't you need to specify to which object library it
belongs, i.e. if you use wrdApp.ActiveDocument.etc. then
wrdApp.wdSendToNewDocument *or* use the enum value?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
Top