Need macro help to close excel

G

Guest

I have created a button in Access2000 that opens an Excel Spreadsheet. What
I need now is assit in closing excel upon completion. I can get an excel
macro to save my file and close the worksheet, but it is not closing excel
entirely. I'm on project with this employer and could use a response today
to fix this before I leave. Thanks much to any and all. My macro is as
follows:

Sub SaveClose()
'
' SaveClose Macro
' Macro recorded 9/27/2004 by cdjohnso
'
' Keyboard Shortcut: Ctrl+Shift+C
'
ChDir "I:\SchoolsSurvey\Graphs_Reports"
ActiveWorkbook.SaveAs Filename:= _
"I:\SchoolsSurvey\Graphs_Reports\Responses_incl_Phase_2.xls",
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
ActiveWorkbook.Close
ActiveWindow.Close
Set excelApp = GetObject(, "Excel.application")
excelApp.Quit
End Sub
 
I

icestationzbra

i would just use these two lines at the end:

ActiveWorkbook.Save

Application.Quit

instead of:

ActiveWorkbook.Close
ActiveWindow.Close
Set excelApp = GetObject(, "Excel.application")
excelApp.Qui
 
S

Sanjay Valiyaveettil

I have edited your code below. after you save, just use
application.quit instead of activeworkbook and
activewindow etc.

Sanjay V.
sanjayva at yahoo dot com

Sub SaveClose()
'
' SaveClose Macro
' Macro recorded 9/27/2004 by cdjohnso
'
' Keyboard Shortcut: Ctrl+Shift+C
'
ChDir "I:\SchoolsSurvey\Graphs_Reports"
ActiveWorkbook.SaveAs Filename:= _
"I:\SchoolsSurvey\Graphs_Reports\Responses_incl_Ph
ase_2.xls",
FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False

Application.quit

' ActiveWorkbook.Close
' ActiveWindow.Close
' Set excelApp = GetObject(, "Excel.application")
' excelApp.Quit
End Sub
 
G

Guest

You are sooooo aaawwwsumm!! I've been banging my head all morning. Now I can
take a deep breath (and a break!!). many thanks!! This is my first exposure
to this forum. You can bet I will bookmark in my mind the web address so I
can use it in my future life!

Thanks Again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top