Is it Possible to Run MS Word?

Topics: Developer Forum
Jan 11, 2013 at 5:38 PM

I am trying to use some code Iwrote for the stand alone version to work in AVFP.  It is program to run mailmerges in MS Word.  I would think it could work. 


Here is some of the code:


#Define wdSendToNewDocument 0
#Define wdDefaultFirstRecord 1
#Define wdDefaultLastRecord -16

loWord = CREATEOBJECT("Word.Application")
lcDocument = "C:\mailmerge\test.doc"


******Perform Merge
cTempFile = "C:\mailmerge\MailMergeData.csv"
loWord.ActiveDocument.MailMerge.OpenDataSource( cTempfile, 0, .F.,,.t.,,,,,,, )

loWord.ActiveDocument.MailMerge.DataSource.FirstRecord = wdDefaultFirstRecord
loWord.ActiveDocument.MailMerge.DataSource.LastRecord = wdDefaultLastRecord


If I stop it before the Perform Merge part it does nothing where it should, at least, open the document.

Any chance this might work and, if so, what am I doing wrong?

Thanks for any help.

Jan 11, 2013 at 8:30 PM

More than likely a Permissions problem.  You have to give proper access rights to the folder you're working with.

If this app is going to get heavy usage by 100s of people at a time, MS-Word might present a scalability issue.  You might want to look at OWC 11 (Office Web COmponents) for a more scalable solution if this is the case.  I went through the same things with Excel and Charts and OWC offered a much more scalable and web friendly solution. 

Jan 12, 2013 at 1:06 AM

That might be the issue.  The server is running on a virtual server.  I did set the security levels on your advice and edited the program down to just launching Word.  Now I get an OLE error.  Looking around it looks like I need set the Component Services for MS Word.  I tried to do that and, for whatever reason, there is no option for MS Word.  That might be about how I log in.  I'll see.

This is going to be a lightly used program.  But, I think I might do a research on OWC.

Thanks for the help.