Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default HELP!!!! Calling a sub from Workbook_BeforeSave

I have a sub called SSave in a module called SLOCSave which I would
like to call in private sub Workbook_BeforeSave but I can't figure out
how.

HELP

John

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default HELP!!!! Calling a sub from Workbook_BeforeSave

Assuming the module is in the spreadsheet and not in an addin or some other
spreadsheet then... (I am assuming that your procedure does a save and that
you do not need to worry about Save vs SaveAs)

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
on error goto ErrorHandler

Cancel = True 'Assuming you want to cancel the save done by the user
Application.enableevents = false 'Assuming your called procedure does a save
Call SLOCSave.SSave

ErrorHandler:
application.enableevents = true
End Sub
--
HTH...

Jim Thomlinson


"RocketMan" wrote:

I have a sub called SSave in a module called SLOCSave which I would
like to call in private sub Workbook_BeforeSave but I can't figure out
how.

HELP

John


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default HELP!!!! Calling a sub from Workbook_BeforeSave

OPPS, I was in an add in (an .xla file) which I can see.
Jim Thomlinson wrote:
Assuming the module is in the spreadsheet and not in an addin or some other
spreadsheet then... (I am assuming that your procedure does a save and that
you do not need to worry about Save vs SaveAs)

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
on error goto ErrorHandler

Cancel = True 'Assuming you want to cancel the save done by the user
Application.enableevents = false 'Assuming your called procedure does a save
Call SLOCSave.SSave

ErrorHandler:
application.enableevents = true
End Sub
--
HTH...

Jim Thomlinson


"RocketMan" wrote:

I have a sub called SSave in a module called SLOCSave which I would
like to call in private sub Workbook_BeforeSave but I can't figure out
how.

HELP

John



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default HELP!!!! Calling a sub from Workbook_BeforeSave

Two possible methods...

1. Application.Run "Book1.xls!ThisWorkBook.MyExcelMacro"
2. Create a reference in your speadsheet to the Addin (Tools - References
- select your addin. this is a lote easier if you have named your addin
something other than the default VBAProject. Right click the addin project
and select properties and change the project name)

Option 2 is a bit more efficient than option 1 as it creates a direct
reference to the addin. That being said the code for your workbook will not
compile on any machine that does not have the addin installed. Option 1 has
the advantage of compiling (but it will thow an error if you try to execute
it) on a machine without the addin. Up to you which direction to go...
--
HTH...

Jim Thomlinson


"RocketMan" wrote:

OPPS, I was in an add in (an .xla file) which I can see.
Jim Thomlinson wrote:
Assuming the module is in the spreadsheet and not in an addin or some other
spreadsheet then... (I am assuming that your procedure does a save and that
you do not need to worry about Save vs SaveAs)

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
on error goto ErrorHandler

Cancel = True 'Assuming you want to cancel the save done by the user
Application.enableevents = false 'Assuming your called procedure does a save
Call SLOCSave.SSave

ErrorHandler:
application.enableevents = true
End Sub
--
HTH...

Jim Thomlinson


"RocketMan" wrote:

I have a sub called SSave in a module called SLOCSave which I would
like to call in private sub Workbook_BeforeSave but I can't figure out
how.

HELP

John




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default HELP!!!! Calling a sub from Workbook_BeforeSave


Jim Thomlinson wrote:
Assuming the module is in the spreadsheet and not in an addin or some other
spreadsheet then...


OPPS forgot to say it was in another spreadsheet add in (.xla ) that I
did add and can see.



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
Calling Column D Trackeous Excel Discussion (Misc queries) 1 December 1st 06 02:42 AM
Calling Column D Trackeous Excel Discussion (Misc queries) 0 November 30th 06 03:42 PM
Calling Column D Stefi Excel Discussion (Misc queries) 0 November 30th 06 02:31 PM
Calling Column D Stefi Excel Discussion (Misc queries) 0 November 30th 06 08:59 AM
Calling an Add-In BillCPA Excel Discussion (Misc queries) 2 August 11th 05 09:32 PM


All times are GMT +1. The time now is 12:37 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"