Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word DOC to text and images
Message
 
To
29/03/2006 00:06:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01108271
Message ID:
01108771
Views:
25
This message has been marked as the solution to the initial question of the thread.
Hi Jos,

There is no object like "page" in the Word document. To deal with your project, the following may help:
oWord = Getobject(,"Word.Application")
lnPageCount=oWord.ActiveDocument.ComputeStatistics(2)
with oWord.Selection
	FOR pnPage=1 TO lnPageCount
		.GoTo(,,,pnPage)
		lnStart=.Range.Start
		if lnPageCount >pnPage
			.GoToNext(1)
			lnEnd=.Range.Start - 1
		else
			.Endkey(6)
			lnEnd=.Range.Start
		endif
		oWord.Activedocument.Range(lnStart,lnEnd).copy

	.........
	
	ENDFOR
ENDWITH
>Hi Yuri
>
>Thanks for the reply. I am looking at your sample and I also have Tamar's book on Office Automation with VFP. I can create the word object and open the document but I cannot see how to create an object reference for page 1,2,3... so that I can dump the text for each page and check for images on that page?
>
>I am also not sure how you are suggesting to use the "oWord.Selection" in your sample snippet?
>
>
>>Hi Jos,
>>
>>I believe, yes, it is possible. One of the scenarious could be like this:
>>
>>- use Word.Automation and scan all pages;
>>
>>oWord = Getobject(,"Word.Application")
>>lnPageCount=oWord.ActiveDocument.ComputeStatistics(2)
>>with oWord.Selection
>>         FOR pnPage=1 TO lnPageCount
>>......
>>
>>
>>- for each page copy the content to the word file, and save it as a text file having name related to pnPage. It will give you the text on the page;
>>
>>- for each page look for the image, picture, InlineShapes, etc. and copy it to the clipboard. Then use the appropriate method to save the clipboard content to the picture file. Search here on examples of using GDI+ .
>>
>>
>>Hope this help.
>>
>>
>>>Hi All
>>>
>>>I have been given a Word document. Each page has an image at the top and some text underneath. Is there a way to automate dumping the image on each page to a file named image_1.jpg, image_2.jpg,...image_n.jpg and dumping the text of each page to a file named text_1.txt, text_2.txt,...text_n.txt, where the numerals in the file names indicate the page number where the image and text came from?
>>>
>>>Thanks
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform