ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close and save macro (https://www.excelbanter.com/excel-programming/283493-close-save-macro.html)

Gordon Cartwright

Close and save macro
 
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.

Bob Phillips[_6_]

Close and save macro
 
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)

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




Dave Peterson[_3_]

Close and save macro
 
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.

Gordon Cartwright wrote:

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.


--

Dave Peterson



All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com