View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Guriuz Guriuz is offline
external usenet poster
 
Posts: 4
Default Close Excel from Access

NickHK il giorno 07/06/2007 alle ore 15:04:17 ha scritto:
You will have problems because you are using unqualified references. e.g.
ActiveChart.ChartType = xlLineMarkers

Always use the object hierarchy from an object that you a reference to. This
is better
oWks.ActiveChart.ChartArea.Select

but it seldom necessary to .Select object before using them (although Chart
stuff maybe one of the situations ??).
Give yourself a variable to work with:
e.g.
Dim NewChart As Chart
set newchart=oWks.Charts.Add()
With newchart
'Everything you need to do to the chart


New code part, but it's no correct (Run-time error -2147221080 in
..HasTitle):

Dim NewChart As Chart
Set NewChart = oWks.Charts.Add()

NewChart.Activate

With ActiveChart
.Name = "mio grafico" '<-- crea un foglio grafico
.ChartType = xlLineMarkers
.SetSourceData Source:=oWks.Sheets("Foglio3").Range("A1"),
PlotBy:=xlColumns
.SeriesCollection.NewSeries
.SeriesCollection(1).XValues = "=Raccolta!R2C1:R8C1"
.SeriesCollection(1).Values = "=Raccolta!R2C2:R8C2"
.Location Whe=xlLocationAsObject, Name:="Foglio2"
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With

Thx.