Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default BeforeSave macro

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default BeforeSave macro

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default BeforeSave macro

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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default BeforeSave macro

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" wrote in message
...
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
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
Run macro with BeforeSave Event JDH Excel Programming 7 June 6th 08 07:54 PM
Trying to run macro on the BeforeSave event dmagoo22 Excel Programming 3 July 5th 06 09:38 PM
BeforeSave Steven Excel Programming 2 January 21st 06 05:37 PM
BeforeSave Sub Phil Hageman[_3_] Excel Programming 6 January 14th 04 10:12 AM
VBA - BeforeSave - NEED HELP HRobertson Excel Programming 2 October 23rd 03 06:50 PM


All times are GMT +1. The time now is 08:06 PM.

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"