How do I determine how excel was launched

  • Thread starter Thread starter Gilgamesh
  • Start date Start date
G

Gilgamesh

I have a file in my XLSTART directory with an Auto_Open macro in it that
obviously runs everytime I start Excel. But I need it to do different
things depending upon how Excel was started so I'm looking to determine this
within the VBA code.
I look at start method 1 as being Excel was selected in the Start Menu (or
quick launch or desktop, etc) so it starts without opening a user selected
file.
And start method 2 was when an excel file was double clicked within windows
explorer (or as mail attachment etc) such that the user selected file opens
with the Excel startup

Any help would be appreciated.

Thank You
 
While not reliable, in the first case wouldn't there be a Book1 (no
extension) and in the second there would not. Of course, everything
doesn't happen instantaneously, so I don't know whether Book1 would be
present at the time your workbook is opened. Guess you would have to test
it.
 
Tom Ogilvy said:
While not reliable, in the first case wouldn't there be a Book1 (no
extension) and in the second there would not. Of course, everything
doesn't happen instantaneously, so I don't know whether Book1 would be
present at the time your workbook is opened. Guess you would have to test
it.

Unfortunately as the file in XLSTART is opened for some reason EXCEL says
there is an open file and does not create the empty Book1 file.
In fact the macro I'm putting together is supposed to generate the Book1
file for easy use to compensate for multiple files in XLSTART. It works
when just launcing excel as per method 1 but the problem I have is that it
also creates a Book1 file when double clicking on an excel file (as well as
opening the selected excel file) as per method 2.
 

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