Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Close Excel from Access

Hello,
from Access make use of sheet of Excel for generate a graph.
Beacuse Excel remain in backgroud execution?
I use this code for close the Workbook without save:

myXLwb.Application.ActiveWorkbook.Close False

and this for close the Excel application:

xlApp.Application.Quit

where mistake?
Thx.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Close Excel from Access


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.

NickHK

"Guriuz" wrote in message
...
Hello,
from Access make use of sheet of Excel for generate a graph.
Beacuse Excel remain in backgroud execution?
I use this code for close the Workbook without save:

myXLwb.Application.ActiveWorkbook.Close False

and this for close the Excel application:

xlApp.Application.Quit

where mistake?
Thx.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Close Excel from Access

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 Whe=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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Close Excel from Access

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

NickHK

"Guriuz" ...
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 Whe=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.




  #5   Report Post  
Posted to microsoft.public.excel.programming
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


Ok NickHK, I will try your solution...
Thx for your availability.




  #6   Report Post  
Posted to microsoft.public.excel.programming
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.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Close Excel from Access

I don't do much charting, so not sure.
There is the ChartObject also, which seems involved in some things
<guesswork...

However, in terms of objects, you are still using the unqualified reference
of ActiveChart. This often means that you will not be able to release all
references to Excel and allow it to close.
Therefore, use the object reference that you have already, NewChart or
oWks.ActiveChart .

NickHK

"Guriuz" wrote in message
...
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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Close Excel tables from Access StacyM Excel Discussion (Misc queries) 0 August 11th 09 09:04 PM
Update Access Query save and close through Excel VBA BigPig Excel Programming 0 May 8th 07 04:01 PM
Open Access, Paste data to table, and close all from Excel Macro learningaccess Excel Programming 2 April 26th 07 04:04 PM
Access.Application.Quit - opens Access again then won't close - He Hluhluwe Excel Programming 0 January 30th 06 11:17 AM
.saveas and .close methods from Access Marius from Rome Excel Programming 0 January 7th 04 05:03 PM


All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"