Run code when ANY file opens

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to run some VBA code on a PC whenever ANY workbook is opened in excel.
It can not only be when excel opens, it need to be even if a new file is
oened once excel is already running. Any suggestions?
 
In a module, create an Auto_Open macro, like:

Public Sub Auto_Open()
'do the hokie pokie
End Sub

Save your file with the .xla extension, to make it an Add-in.
Pick Extra/Add-ins and check your own file. After that, it'll always run
when Excel is opened.
 
Will this work then on a file that is opened and excel is already running?
 
It only runs when the addin gets loaded - it has nothing to do with any other
file being opened. So the short answer is no.
 
thuoght so. Your suggestion works fine. It seems that the application that
is launching the ecel files I want to edit is able to bypass the code I put
in. Is it possible for apps to code in to bypass the Open function? If they
did, any other options to force my code anyways or am I out of luck?
 
I suspect if excel is being launched by some other application, then your
addin isn't being loaded. There wouldn't be a way around this that I could
think of. When excel is opened via automation, it doesn't load addins or
files in the xlstart directory.

Just a guess that your code is correct and that is what is happening.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top