Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Picture in report
Message
From
06/09/2002 06:26:26
 
 
To
07/08/2001 09:30:15
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Miscellaneous
Thread ID:
00540069
Message ID:
00697406
Views:
17
how to do all this in excel


Mohammed,

The example below takes a text file and converts it into a word doc. If you want to model a file after an existing Foxpro report (frx) run the report with the 'to file' option. Or produce a text file with what ever means you like. Then, the code below can convert the text file into a document file. While running it you can format the text file anyway you would like by using the built in features of Microsoft Word. Below is just a small sample but with OLE you can automate Word to do anything Word can do.
If you are not sure what the command syntax is to automate Word to do something you can look at the Word macro code it produces. ie: Go into Word and start a macro and then do something in Word that you want to be able to do from Foxpro. Then stop the marco and look at the vb code it made to find out what commands it used. The syntax will not be Foxpro syntax but it usually gives you enough clues to figure out what the Foxpro syntax is. If that does not help I'm sure there are some good books out there that would help you out.

&& Creates a word object.
oleapp = createobject('word.application')

&& Lets you see Word while Foxpro has it opened. (Good for debugging. In your final app set this to .f.

oleapp.visible = .t.

&& Opens a file.
oleapp.documents.open('c:\config.sys')

&& Does some formatting on the whole doc.
oleapp.selection.wholestory
oleapp.selection.font.size = 10
oleapp.selection.font.name = 'Arial'
oleapp.selection.paragraphformat.leftindent = 0
oleapp.selection.paragraphformat.rightindent = 0
oleapp.selection.homekey

&& Does some formatting on a specific part of the doc.
oleapp.Selection.MoveDown(,3,1)
oleapp.Selection.ParagraphFormat.Alignment = 1
oleapp.Selection.Font.Bold = .t.
oleapp.selection.font.size = 11
oleapp.selection.MoveDown(,1)
oleapp.selection.homekey

&& Adds a picture to the document. Argument two is the link to file option and argument three is save with doc option.

oleapp.selection.inlineshapes.addpicture('c:\test.jpg', .f., .t.)

&& Saves the file. Argument two specifes the save type. You can save it in any format Word can save it in.

oleapp.documents('c:\config.sys').saveas('c:\test.doc', 0)

&& Closes the doc and releases the object.

oleapp.documents('c:\test.doc').close
oleapp.quit

release oleapp


I hope this helps!
Previous
Reply
Map
View

Click here to load this message in the networking platform