Close macro not saving my changes

dfuas

Registered User.
Local time
Today, 03:23
Joined
Jan 4, 2006
Messages
66
Hi

I just wrote my first macro in Excel, but the problem is not saving any changes I make when I click the close button on the right top corner.
Can anyone help, please?

Sub Auto_Close()

Dim OrigName As String
OrigName = ActiveWorkbook.FullName
ActiveWorkbook.Save

End sub

thanks
dfuas
 
Hi, dfuas,

and where did you place the macro? It should be in a normal code module. Anyhow - as no changes are being made to the name of the workbook the following code should do the job:

Code:
Sub Auto_Close()

ThisWorkbook.Save 'will only save workbook with code

End Sub
And I would prefer to use the Workbook_BeforeClose(Cancel As Boolean)-event to save the workbook (code goes into ThisWorkbook):

Code:
Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub
If code doesn´t work did you set the security level for macros to medium and starting with Excel2002 the checkbox near to trust VBA-Project (don´t know the proper expression in english - sorry)?

Ciao,
Holger
 

Users who are viewing this thread

Back
Top Bottom