LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Running code before any file is opened/saved

I found the below code posted around Nov 2005:

In a new Class module name clsXLEvents
Option Explicit
Private WithEvents xlApp As Excel.Application


Private Sub Class_Initialize()
Set xlApp = Excel.Application
End Sub


Private Sub xlApp_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal
SaveAsUI As
Boolean, Cancel As Boolean)
MsgBox "Tada"
End Sub


In a standard module named whatever
Option Explicit


Public xlApp As clsXLEvents


And in ThisWorkbook
Option Explicit


Private Sub Workbook_AddinInstall()
Set xlApp = New clsXLEvents
End Sub


Private Sub Workbook_AddinUninstall()
Set xlApp = Nothing
End Sub


Private Sub Workbook_Open()
Set xlApp = New clsXLEvents
End Sub

---

My question is is there a way to make a global Workbook_Open code?

I tried adding:

Private Sub xlApp_Workbook_Open(ByVal Wb As Workbook)

MsgBox "Open"

End Sub

In 'clsXLSEvents', but to no avail.

 
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
Formatting not saved when file re-opened rzink Excel Discussion (Misc queries) 0 December 14th 09 06:18 PM
How do I recover excel file opened through email and not saved Liane Excel Discussion (Misc queries) 6 June 28th 06 06:59 PM
Determine if XL file opened from Outlook or a saved file quartz[_2_] Excel Programming 1 September 16th 05 09:50 PM
Excel file opened as read-only, if saved by another user GeEf Excel Discussion (Misc queries) 2 August 28th 05 04:29 PM
Excel vba code disappears when saved workbook is re opened Joshua Fandango[_2_] Excel Programming 5 April 5th 05 04:12 PM


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