I'm using an addin for a macro, and need to test for the workbook name.
The code below works but the macro "initial_do" runs twice.
Tried to call up from Workbook_Open but no luck.
One of the difficulties seems to be that getting workbook name seems to be triggered after Workbook_Open.
ThisWorkbook
Module1
The code below works but the macro "initial_do" runs twice.
Tried to call up from Workbook_Open but no luck.
One of the difficulties seems to be that getting workbook name seems to be triggered after Workbook_Open.
ThisWorkbook
VBA Code:
Option Explicit
Private WithEvents App As Application '... for new Workbooks???
Private Sub Workbook_Open()
Set App = Application
End Sub
'To handle workbooks opened after the first instance???
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
Application.Run "initial_stuff"
End Sub
Module1
VBA Code:
Option Explicit
Public RunWhen As Double
Public Const RunIntervalSeconds = 0
Public Const RunWhatInitial = "initial_do"
Private Sub initial_stuff()
RunWhen = Now + TimeSerial(0, 0, RunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=RunWhatInitial, Schedule:=True
End Sub
Private Sub initial_do()
MsgBox ActiveWorkbook.FullName
End Sub