Close and save macro

  • Thread starter Thread starter Gordon Cartwright
  • Start date Start date
G

Gordon Cartwright

Hi...

I'm struggling with some code...I want to hit a macro
button that will save changes, save the file to the
desktop and close excel...I'm close but no cigar.

Any help useful...

Cheers

Gordon.
 
Gordon,

OKI< so show us what you've got and we'll go from there.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
I wouldn't close excel--the user might be working on lots of other files!

Option Explicit
Sub testme03()

Dim wsh As Object
Dim myPath As String

Set wsh = CreateObject("WScript.Shell")
myPath = wsh.SpecialFolders.Item("Desktop")

ActiveWorkbook.SaveAs Filename:=myPath & "\" & "whateveryouwant.xls", _
FileFormat:=xlWorkbookNormal

'Application.Quit
'or just close the activeworkbook
'ActiveWorkbook.Close savechanges:=False

End Sub

I think a lot of users would come looking for you if running your macro caused
them to lose work in other workbooks.
 
Back
Top