Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert Excel Chart in Word
Message
De
19/07/2011 16:04:18
 
 
À
19/07/2011 14:57:17
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01518504
Message ID:
01518542
Vues:
43
>>Hi,
>>
>>I am trying to create a chart in Excel and then place it in a Word document.
>
>When I did this for a client last year, I found that it worked best to save the chart, close Excel and then use Word's InlineShapes.AddOLEObject method to put the chart into the document. The key part of my code looks like this, where cChartFile contains the name of the chart file.
>
>
>	oRange = oDoc.Bookmarks["Graph"].Range()
>	oRange.Collapse(0)
>	
>	oChart = oDoc.InlineShapes.AddOLEObject(, m.cChartFile, .F., .F., , , ,m.oRange)
>
>
>Tamar

Thanks Tamar,

that's one step closer in that the chart has been pasted next to the bookmark, but not replaced the bookmark. Also, the picture of the graph, plus the underlying worksheet is displayed whereas I just want the chart. How do you create your chart. I have code like this:
    			m.loChart1 = m.loXLSheet.ChartObjects.Add(100, 100, 200, 200)

			    With m.loChart1.Chart
	    			.ApplyCustomType(xlBuiltIn, "Lines on 2 Axes")
					.SetSourceData(m.loXLSheet.Range("A1:D7"), xlColumns)
					.SeriesCollection(1).Delete
					.SeriesCollection(1).Delete
					.Location(xlLocationAsObject, "Sheet1")
			        .HasTitle = .T.
			        .ChartTitle.Characters.Text = "Claims Received/Turnaround"
			        .Axes(xlCategory, xlPrimary).HasTitle = .T.
			        .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
			        .Axes(xlValue, xlPrimary).HasTitle = .T.
			        .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Claims Received"
*!* these are giving an error which I have not yet worked on
*!*				        .Axes(xlCategory, xlSecondary).HasTitle = .T.
*!*				        .Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text = ""
*!*				        .Axes(xlValue, xlSecondary).HasTitle = .T.
*!*				        .Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Avg. Turnaround"
			    EndWith
			    With m.loChart1.Chart.Axes(xlCategory)
			        .HasMajorGridlines = .F.
			        .HasMinorGridlines = .F.
			    EndWith
			    With m.loChart1.Chart.Axes(xlValue)
			        .HasMajorGridlines = .T.
			        .HasMinorGridlines = .F.
			    EndWith
			    m.loChart1.Chart.HasDataTable = .F.
    
				m.lcChartFile = ADDBS(m.loCommonFolder.getfolder(CSIDL_PERSONAL)) + ;
					FORCEEXT(ALLTRIM(c_ClaimsTurnAround.cli_name) + "-Turnaround", "XLS")
				m.loXLSheet.Saveas(m.lcChartFile)

				IF !m.lHasExcel97
					m.loXLSheet.APPLICATION.QUIT
				ENDIF
				RELEASE m.loXLSheet

				oRange = m.loDoc.Bookmarks["TurnaroundChart"].Range()
				oRange.Collapse(0)
				
				oChart = m.loDoc.InlineShapes.AddOLEObject(, m.lcChartFile, .F., .F., , , ,m.oRange)
What does the Range.Collapse(0) do?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform