PC Review


Reply
Thread Tools Rate Thread

BeforeSave macro

 
 
Kiba
Guest
Posts: n/a
 
      17th Oct 2008
I get and error when i try to run a module named 'Merge' in the workbook
section before save.

Sub Workbook_BeforeSave()

Merge

End Sub

How can I make this work?
 
Reply With Quote
 
 
 
 
Doug Glancy
Guest
Posts: n/a
 
      17th Oct 2008
Kiba,

I see three possible problems:

1. "Merge" is an Excel reverved word, so it's not a good choice for a sub
or function name. Change the name from "Merge" to something else.
2. If it's really a module name, you can't "run" a module, so that might be
the problem in that case.
3. A Workbook_BeforeSave event really starts like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
The best way to create this event is to go into the ThisWorkbook module,
choose "Workbook" in the dropdown at the top left and choose the event in
the dropdown at the top right.

hth,

Doug

"Kiba" <(E-Mail Removed)> wrote in message
news:CB85F2EB-9AEA-4E50-94DA-(E-Mail Removed)...
>I get and error when i try to run a module named 'Merge' in the workbook
> section before save.
>
> Sub Workbook_BeforeSave()
>
> Merge
>
> End Sub
>
> How can I make this work?



 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      17th Oct 2008
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call merge
End Sub

merge must be in a standard module.
--
Gary''s Student - gsnu200808


"Kiba" wrote:

> I get and error when i try to run a module named 'Merge' in the workbook
> section before save.
>
> Sub Workbook_BeforeSave()
>
> Merge
>
> End Sub
>
> How can I make this work?

 
Reply With Quote
 
Doug Glancy
Guest
Posts: n/a
 
      17th Oct 2008
Gary''s Student ,

"merge must be in a standard module."

Actually it can be in the ThisWorkbook module. Also, the OP doesn't need to
start using Call. For example, this code can all be in the ThisWorkbook
module:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Test
End Sub

Sub Test()
MsgBox "test"
End Sub

Doug

"Gary''s Student" <(E-Mail Removed)> wrote in message
news:9B3BD644-A020-41E1-931E-(E-Mail Removed)...
> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
> Boolean)
> Call merge
> End Sub
>
> merge must be in a standard module.
> --
> Gary''s Student - gsnu200808
>
>
> "Kiba" wrote:
>
>> I get and error when i try to run a module named 'Merge' in the workbook
>> section before save.
>>
>> Sub Workbook_BeforeSave()
>>
>> Merge
>>
>> End Sub
>>
>> How can I make this work?



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
beforesave macro help Arran Microsoft Excel Programming 6 31st Jul 2009 04:49 PM
Run macro with BeforeSave Event JDH Microsoft Excel Programming 7 6th Jun 2008 07:54 PM
Trying to run macro on the BeforeSave event dmagoo22 Microsoft Excel Programming 3 5th Jul 2006 09:38 PM
BeforeSave Sub Phil Hageman Microsoft Excel Programming 6 14th Jan 2004 10:12 AM
VBA - BeforeSave - NEED HELP HRobertson Microsoft Excel Programming 2 23rd Oct 2003 06:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:02 AM.