Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default WorkbookBeforeSave Problem

Excel 2007

I copied two macro examples from the Excel Help File and tried to run them,
but I get an error message that says:


Cannot run the macro €˜MacroName.xlsm. The macro may not be available in
this workbook or all macros may be disabled.

I have enabled all macros. But still get that message.
The macro is in my Personal.xls file in the XLSTART folder. And even when I
open THAT file and try to run the macro, it doesn't work. Same message.

The macros I have copied from Help (there are two) a

Option Explicit
Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel As Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub


Please help.
Thanks


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default WorkbookBeforeSave Problem

Those are events that run automatically when the workbook closes or is
saved.

They are not macros that you "run".

They have no names and cannot be run manually.

Must be placed into the Thisworkbook module of whatever workbook you want
them to run from.

They will not run from Personal.xls on any other workbook.


Gord Dibben MS Excel MVP



On Sat, 31 Oct 2009 06:07:01 -0700, Steve
wrote:

Excel 2007

I copied two macro examples from the Excel Help File and tried to run them,
but I get an error message that says:


Cannot run the macro ‘MacroName.xlsm’. The macro may not be available in
this workbook or all macros may be disabled.

I have enabled all macros. But still get that message.
The macro is in my Personal.xls file in the XLSTART folder. And even when I
open THAT file and try to run the macro, it doesn't work. Same message.

The macros I have copied from Help (there are two) a

Option Explicit
Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel As Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub


Please help.
Thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default WorkbookBeforeSave Problem

Thank you, Gord. You've given me a better uderstanding of how this stuff
works.



"Gord Dibben" wrote:

Those are events that run automatically when the workbook closes or is
saved.

They are not macros that you "run".

They have no names and cannot be run manually.

Must be placed into the Thisworkbook module of whatever workbook you want
them to run from.

They will not run from Personal.xls on any other workbook.


Gord Dibben MS Excel MVP



On Sat, 31 Oct 2009 06:07:01 -0700, Steve
wrote:

Excel 2007

I copied two macro examples from the Excel Help File and tried to run them,
but I get an error message that says:


Cannot run the macro €˜MacroName.xlsm. The macro may not be available in
this workbook or all macros may be disabled.

I have enabled all macros. But still get that message.
The macro is in my Personal.xls file in the XLSTART folder. And even when I
open THAT file and try to run the macro, it doesn't work. Same message.

The macros I have copied from Help (there are two) a

Option Explicit
Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, Cancel As Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub


Please help.
Thanks


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sum problem hitesh Excel Discussion (Misc queries) 1 November 11th 06 04:40 PM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
I've a problem Wojtek Laskowski Excel Discussion (Misc queries) 1 March 22nd 06 12:30 AM
I have this problem... dalipsinghbisht Excel Discussion (Misc queries) 3 March 21st 06 11:21 AM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM


All times are GMT +1. The time now is 09:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"