PDA

View Full Version : Solved: How to let Excel "monitor" for opening or closing a random file?



PcsTvW
04-05-2013, 03:06 AM
Hello,

Is there a way in VBA to, for example, get a msgbox when a random file is opened in Excel (Office2000)?
Just using:


Sub WorkBook_Open()



Msgbox "New file opened"

End Sub

...will not work because the code is placed in the ThisWorkBook section of a certain file and stored within this file itselves. So only when that file opens it comes with the msgbox. So in fact Excel needs to "monitor" whether a file opens and then give me msgbox.

So what code is needed and where do I place the code like the "ThisWorkBook-section" above or in a new module? I thought I need to store it in an Application environment or something but I'm not sure. Can someone help me out?

Thanks in advance,
Tim.

SamT
04-05-2013, 08:52 AM
Application WorkbookOpen Event ?

snb
04-05-2013, 09:48 AM
What triggers the opening of the workbook ?

mdmackillop
04-05-2013, 10:22 AM
Follow the instructions here, adding the code to Personal.xls or other workbook opened on StartUp

http://www.jkp-ads.com/articles/FixLinks2UDF01.asp

In the Class module make this change
MsgBox Wb.name
'ProcessNewBookOpened Wb


Add this to the Workbook module

Private Sub Workbook_Open()
Call InitApp
End Sub

PcsTvW
04-08-2013, 01:57 AM
Hello all that helped me out,

Problem solved! I needed to try and retry several things but now it works fine. I made an add-in and that's what does the job. Thank for your help!

Regards,
Tim.
:beerchug: