Monitoring

serpex

New Member
Joined
Aug 19, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hey All,

Windows Office 365 (Excel Version 2306)

I have taken over maintaining a global macro file that is stored in XLSTART so everyone in the office shares the same macros for every single excel sheet opened.

I want to be able to detect when a new xlsx/xlsm file is opened and record the filename, if it has a specific prefix it will execute some code specific to it.
I have made a module with auto_open() however the macro file in XLSTART launches first and executes the code before the actual file is opened.

Is what im trying to achieve possible?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Solved

VBA Code:
Public WithEvents App As Application
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
    If Left(Wb.Name, 2) = "NP" Then
        MsgBox "NP Sheet: " + Wb.Name
    End If
End Sub
Public Sub Workbook_Open()
    Set App = Application
End Sub
 
Last edited by a moderator:
Upvote 0
When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you this time. 😊
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top