Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FoxPro Automation Problem

Status
Not open for further replies.

RodBurns

Programmer
Jul 11, 2016
7
US
Hello,

First post here, but I've been searching the archives and don't see a solution to a problem I'm having.

We have a VFP 9 application that filters a table for all records that have a "selected" field set. It then scans through that filtered table, takes a bookmark name from another field and searches a Word for that bookmark. If it finds that bookmark in the word document, it selects the text, and appends it to a different word document.

We just switched from Office 2010 to Office 2016 and now this program fails. Here is the portion of code that is failing:

Code:
SELECT program_options
REINDEX 

fi = "DocumentParts.docx"
 
COUNT TO NumSelected FOR selected = .T.

oWord = CREATEOBJECT("Word.Application")
oWord.Visible = .T. 
oWdDestDoc = oWord.Documents.Add()
oWdSourceDoc = oWord.Documents.Open(fi)

SCAN
	IF selected AND LEN(ALLTRIM(WdBookMark)) > 0
		mWdBookMark = ALLTRIM(wdBookmark)
		
		oWdSourceDoc.activate
		IF oWord.ActiveDocument.Bookmarks.Exists(mWdBookMark)

			*** Copy Body ********************
			oWdSourceDoc.Bookmarks(mWdBookMark).select
			oWord.Selection.Copy

		 	oWdDestDoc.activate

At this point, the program dies with an OLE error saying "the object invoked has disconnected".

While watching the program run, it appears that the line "oWdDestDoc = oWord.Documents.Add()" is not actually creating a new word document to allow the program to paste into it (at least one doesn't show up on the task bar as it previously did).

Is there a different way we have to do this in Office 2016?

Thanks to anyone who can help :)
 
Let me see, I also have Office 2010 on an older machine. I can try that later. I don't think it differs.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top