Automate Microsoft Word and Excel Sample

File: ...\Samples\Solution\OLE\Oleaut1.scx

This is a simple sample showing Visual FoxPro as an Automation controller. It demonstrates how to select data from a Visual FoxPro database, place the data in a Microsoft Excel worksheet, graph the data using Chart, and then display the graph in Word. To use this sample, you need at least Excel 5.0, Word 6.0, and Testdata.dbc, located in the ...\Samples\Data directory.

The following line of code creates a reference to a Microsoft Excel spreadsheet.

 CopyCode imageCopy Code
objXLsheet=createobject("Excel.Sheet")

The following line of code adds a chart to the spreadsheet.

 CopyCode imageCopy Code
objChart1 = objXLsheet.ChartObjects.Add(100, 100, 200, 200)

The following line of code creates a reference to Microsoft Word.

 CopyCode imageCopy Code
objWDdoc=createobject("word.basic")
oWordRef = GetObject('','word.basic')

See Also


© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic