NickHK il giorno 07/06/2007 alle ore 12:53:54 ha scritto:
> Assuming myXLwb is a reference to a workbook
> myXLwb.close false
> set myXLwb=nothing
>
> And assuming XLApp is a reference to your instance of Excel
> xlApp.Quit
> set xlapp=nothing
>
> Also assumes that myXLwb is the only WB that you are working on.
This is my code:
Dim oRst As New ADODB.Recordset
Set oRst = New ADODB.Recordset
oRst.CursorLocation = adUseClient
oRst.Open "Select Campo1, Campo6 From Tabella1;",
CurrentProject.Connection
Dim oApp As Excel.Application, oWks As Excel.Workbook
Set oApp = CreateObject("Excel.Application")
Set oWks = oApp.Workbooks.Add()
oApp.Visible = True
oWks.Sheets(1).Name = "Raccolta"
With
oWks.Sheets("Raccolta").QueryTables.Add(oRst,oWks.ActiveSheet.Range("A1"))
.Name = "Query1"
.FieldNames = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
oWks.Charts.Add().Name = "my graph"
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=oWks.Sheets("Foglio3").Range("A1"),
PlotBy:= _
xlColumns
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=Raccolta!R2C1:R8C1"
ActiveChart.SeriesCollection(1).Values = "=Raccolta!R2C2:R8C2"
ActiveChart.Location Where:=xlLocationAsObject, Name:="Foglio2"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
oWks.ActiveChart.ChartArea.Select
oWks.ActiveChart.ChartArea.Copy
DoCmd.OpenForm "Maschera2"
Forms!Maschera2!AssociatoOLE0.OLETypeAllowed = acOLELinked
Forms!Maschera2!AssociatoOLE0.Action = acOLEPaste
Forms!Maschera2!AssociatoOLE0.UpdateOptions = acOLEUpdateManual
Forms!Maschera2!AssociatoOLE0.SizeMode = acOLESizeStretch
Forms!Maschera2!AssociatoOLE0.ControlTipText = "Il nostro grafico!"
oWks.Close False
Set oWks = Nothing
oApp.Quit
Set oApp = Nothing
Set oRst = Nothing
End Sub
But:
http://img249.imageshack.us/img249/4904/snap1ny7.jpg
Misunderstand... uff!
Thx.