ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Problem with Before_Save Macro (https://www.excelbanter.com/excel-discussion-misc-queries/87964-problem-before_save-macro.html)

Jay

Problem with Before_Save Macro
 
Hello All,
I am having a problem with the before_save macro:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
For Each sh In Sheets
sh.Visible = xlSheetVeryHidden
Worksheets("Overview").Visible = True
Next sh
Next
End Sub

It does nothing when I save. The macro doesn't seem to run at all. If
anyone could help me on this, I would appreciate it.
Jason


Bob Phillips

Problem with Before_Save Macro
 
Firtsly, it needs to be in ThisWorkbook code module.

Also, it is broken

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Worksheets("Overview").Visible = xlSheetVisible
For Each sh In ThisWorkbook.Sheets
sh.Visible = xlSheetVeryHidden
Next sh
End Sub

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Jay" wrote in message
oups.com...
Hello All,
I am having a problem with the before_save macro:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
For Each sh In Sheets
sh.Visible = xlSheetVeryHidden
Worksheets("Overview").Visible = True
Next sh
Next
End Sub

It does nothing when I save. The macro doesn't seem to run at all. If
anyone could help me on this, I would appreciate it.
Jason




Jay

Problem with Before_Save Macro
 
Bob,
I do have it in ThisWorkbook, and I attempted to fix it, and it still
doesn't work.
Jay


Bob Phillips

Problem with Before_Save Macro
 
In the immediate window in the VBIDE type

Application.EnableEvents = True

and return.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Jay" wrote in message
oups.com...
Bob,
I do have it in ThisWorkbook, and I attempted to fix it, and it still
doesn't work.
Jay




Jay

Problem with Before_Save Macro
 
Hey Bob,
Sorry for the late response, thank you, it worked.
Jason


Jay

Problem with Before_Save Macro
 
Hey Bob,
Sorry for the late response, thank you, it worked.
Jason



All times are GMT +1. The time now is 01:34 AM.

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