Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP7 SP1 - More Automation Woes with Word now!
Message
From
30/01/2002 10:53:39
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
VFP7 SP1 - More Automation Woes with Word now!
Miscellaneous
Thread ID:
00612757
Message ID:
00612757
Views:
56
Jim:

You recall the unfixed problem I reported with Outlook 2000 giving the "not a parameter error". Unfortunately, I have had a couple more days of grief trying to solve a problem automating Word where it appears that VFP7 SP1 is again, part of the problem.

The following code doesn't run in VFP7 SP1. It just hangs after the first iteration of the main loop. I struggled with it (I wrote it for the first time using VFP7). I thought maybe my RTF files were somehow corrupt. That wasn't the problem. I saved as .DOC files - that wasn't the problem. By chance, I ran the code in VFP6 SP5 and bing - worked like a charm?

After waiting for SP1 to fix the Outlook problem and it didn't, to now find that I can't run this in SP1 is a blow. At this stage, I am rapidly losing confidence in VFP7. I have been running VFP7 SP1 on Win2000 SP2 and used Word2000 from Office 2000 Professional version 9.0.3821 SR1. The code is as follows, if you want the RTF documents, let me know. Thanks.
#include word2000.h

Set Step On
*---------------------
Local oPages, nPageCount
lcfile1="c:\TEMP\L80UJ5P5.RTF"
oWord = Createobject("word.application")

oWord.Documents.Open(lcfile1)
* Represents the browser tool used to move the insertion point to
* objects in a document. We are browsing "Pages" on this occasion.
m.oword.Application.Browser.Target = wdBrowsePage
* Get a reference to the pages object.
m.oPages = oWord.Activedocument.BuiltInDocumentProperties(wdPropertyPages)
* Record the page object's value property (the number of pages).
m.nPageCount = m.oPages.Value
* Iterate through the pages in the document.
For m.nKount = 1 To m.nPageCount
* Get a range on the "current" page. We can do this using the
* in-built "\page" bookmark.
	oRange = oWord.Activedocument.bookmarks("\page").Range()
* If we are on the one before last page, we have to delete
* the application added page break.

	If m.nKount = m.nPageCount - 1
		oRange.Collapse(wdCollapseEnd)
		oRange.Select()
		oWord.Selection.typebackspace()		&& Lone space.
		oWord.Selection.typebackspace()		&& PageBreak.
		oWord.Selection.InsertBreak(wdSectionBreakNextPage)
	Else
		oRange.Collapse(wdCollapseEnd)
		oRange.InsertBreak(iif(m.nKount==m.nPageCount, wdSectionBreakNextPage, wdSectionBreakContinuous))
	Endif

	m.oWord.Application.Browser.Next()
Endfor

lcfile2="c:\TEMP\L80UJ5RX.RTF"
oRange.InsertFile(lcfile2,"", .F.,.F.,.F.)


oWord.Visible=.T.
oWord.Quit(wdDoNotSaveChanges)
-=Gary
Next
Reply
Map
View

Click here to load this message in the networking platform