Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Insert Excel Chart in Word
Message
From
19/07/2011 09:54:33
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Insert Excel Chart in Word
Miscellaneous
Thread ID:
01518504
Message ID:
01518504
Views:
89
Hi,

I am trying to create a chart in Excel and then place it in a Word document.

I have created the chart and put a bookmark in the document, but the image of the chart is not pasted where the bookmark is. Here's my code:
loWord = CREATEOBJECT("Word.Application")
SCAN 
	loWord.Documents.Add("GroupPlan.dot")
	m.loDoc = m.loWord.ActiveDocument
	
	objXLsheet=CreateObject("Excel.Sheet")

	* Excel 97 Automation change
	* CreateObject() returns Object instead of Sheet1
	IF UPPER(objXLsheet.Name)= "OBJECT"
		lHasExcel97 = .T.
		objXLsheet = objXLsheet.Sheets[1]
	ELSE
		lHasExcel97 = .F.
	ENDIF

	m.lnRowCount = 0
	SCAN 	
		m.lnRowCount = m.lnRowCount + 1 
		objXLsheet.Cells[m.lnRowCount,1].Value = c_TurnaroundChart.Y
		objXLsheet.Cells[m.lnRowCount,2].Value = c_TurnaroundChart.M
		objXLsheet.Cells[m.lnRowCount,3].Value = c_TurnaroundChart.TotalReceived
		objXLsheet.Cells[m.lnRowCount,4].Value = c_TurnaroundChart.AvgTurnaround
	ENDSCAN
	
	objChart1 = objXLsheet.ChartObjects.Add(100, 100, 200, 200)

	objxlsheet.chartobjects(1).chart.;
		chartwizard(objxlsheet.range(objxlsheet.cells(1,1),objxlsheet.cells(m.lnRowCount,4)),;
		-4100,4,1,0,1,1,"","","","")
	*!*	objXLsheet.application.visible=.T.

	ObjXLsheet.ChartObjects(1).select
	ObjXLsheet.ChartObjects(1).copy

	IF !m.lHasExcel97
		objXLsheet.application.quit
	ENDIF
	release objXLsheet

 	IF m.loDoc.Bookmarks.EXISTS("TurnAroundChart")
		m.loDoc.Bookmarks("TurnAroundChart").SELECT
		m.loDoc.APPLICATION.Selection.Paste()	&&.PasteSpecial(,,,,'PICT')
	ENDIF
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform