Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Work with only one Instance of Word
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Work with only one Instance of Word
Miscellaneous
Thread ID:
00658782
Message ID:
00658782
Views:
55
I have a command button labeled "Edit Letter" to enable my users to edit letters used within my app. I am trying to properly launch only a single instance of Word. Currently in the click event, I have:
LOCAL lcDocument
lcDocument = FULLPATH("letters\pcb"+ This.Parent.cboLetterType.Value+".doc")
oWord = CreateObject("Word.Application")
oDoc = oWord.Documents.Open(lcDocument)
oWord.Visible = .T.
I understand that with this code, if the user clicks the button a second time without closing Word, a second instance is created thereby consuming memory. Now according to VFP Documentation AND Tamar Ganor's book MS Office Automation With VFP, I should be able to use the GetObject() function to either create an instance of Word if needed or if Word is already started, simply open the document. I have tried the following with the same assignment as above to lcDocument:
oDoc = GetObject(lcDocument)
oDoc.Visible = .T.
The second line returns an "OLE error code... Unknown Name."

I've tried
oDoc = GetObject(lcDocument, "Word.Application")
oDoc.Visible = .T.
The first line returns an "OLE error code....No such interface supported."

I'm just not understanding the GetObject() function. Isn't this what I want to use prevent the second launch of MS Word?

Thank you very much
Elgin Rogers
Epic Solutions
www.epicsolutions.net
Next
Reply
Map
View

Click here to load this message in the networking platform