Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert Word macro to code
Message
From
10/04/2012 17:04:10
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01353435
Message ID:
01540900
Views:
45
Hello All,

I found this OLD thread (2008) from back when I was trying to convert a Word macro to work in my code. What it did was open Word, open an existing document, merge it, print the results and close Word. Code below:

#define wdSendToPrinter 1
#define wdDefaultFirstRecord 1
#define wdDefaultLastRecord -16

LOCAL oWord

oWord = CREATEOBJECT([Word.Application]) && W/o this nothing can work, even VFP9 :-))))
oWord.Documents.Open(m.dir+"GUESTLABELS.DOC")
With oWord.ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = .t.
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
EndWith
.Execute()
EndWith
#DEFINE wdDoNotSaveChanges 0
#DEFINE wdSaveChanges -1
#DEFINE wdPromptToSaveChanges -2

oWord.Quit( wdDoNotSaveChanges )

I get an error when it hits: .Destination = wdSendToPrinter
The error I receive is: "OLE IDispatch code 0 from Microsoft Word: 'Destination' is not a by reference property'"

I suspect I've run into some sort of conflict with more recent versions of Word? Just a guess. Any suggestions are greatly appreciated.

Martha
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform