Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel automation problem
Message
De
01/03/2006 13:50:27
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
01/03/2006 11:53:55
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
01100443
Message ID:
01100543
Vues:
9
>Hi
>
>I have a problem creating a chart on a sheet in a workbook.
>
>.ActiveChart.Location(xlLocationAsObject,"Summary Source")
>
>should create the chart on the sheet titled "Summary Source". This is the second sheet of four.
> But the chart is being created on the first sheet
>
>I tried selecting the sheet with
>
>.Sheets("Summary Source").Select
>
>and in Excel that is showing as the selected sheet but the chart still goes on the first sheet.
>
>Any ideas what I am doing wrong.
>
>Thanks
>
>Nick Mason

Nick,
I haven't tried doing with .ActiveChart. This works for me:
#include xlconstants.h
Local oExcel as "Excel.Application"
oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Add()
oExcel.Visible= .T.
oExcel.ActiveWorkbook.Worksheets(2).Name = "Summary Source"
With oExcel.ActiveWorkbook.ActiveSheet
 .Range("A1").FormulaR1C1 = "Prod1"
 .Range("B1").FormulaR1C1 = "Amount"
 .Range("C1").FormulaR1C1 = "Code"
 .Range("A2").FormulaR1C1 = "111"
 .Range("A3").FormulaR1C1 = "222"
 .Range("A4").FormulaR1C1 = "333"
 .Range("B2").FormulaR1C1 = "11"
 .Range("B3").FormulaR1C1 = "22"
 .Range("B4").FormulaR1C1 = "33"
 .Range("C2").FormulaR1C1 = "1"
 .Range("C3").FormulaR1C1 = "2"
 .Range("C4").FormulaR1C1 = "3"
 .Range("A1:C4").Select
 .Range("C4").Activate
 .ChartObjects.Add( ;
 oExcel.CentimetersToPoints( 3 ), ;
 oExcel.CentimetersToPoints( 2 ), ;
	oExcel.CentimetersToPoints( 11 ), ;
oExcel.CentimetersToPoints( 11 ))
 With .ChartObjects(1).Chart
  .ChartType = xlBarStacked
  .SetSourceData( oExcel.ActiveWorkbook.ActiveSheet.Range("A1:C4"), xlColumns)
  .Location( xlLocationAsObject, "Summary Source" )
 Endwith
Endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform