how to add a sub at the application level open event?

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

Guest

Greetings,

How do I add a subroutine at the application level?

Example: When I start up Excel I want to have it bring up a messagebox that
says "test"

I can see in the VB editor how to do this at the workbook level in the
workbook open event. But I need to do this at the application level.

Thanks.
Rich
 
Already went there. The last time I needed to do something like this was in
Excel 97 and I believe they had an Application level in the Project browser
and then the ThisWorkbook selection for respective workbooks. I have done
this before, but years ago.

If I add code to thisworkbook, won't that only run when I open Thisworkbook?
In need to invoke a sub right when Excel Starts, kind of like the AutoExec
macro or OnStartup in an Access mdb.

May I ask if you could show me a sample, maybe I need to use an xla or
something? A sample of where I would place a simple sub like

Sub TestOpen()
msgbox "test"
End Sub

so that as soon as I click on my Excel icon as excel opens up I get the
"Test" message?

Thanks.
 
Thanks for that suggestion. So I record an Open workbook macro and then
copy that code to personal.xls?

Wait. I think it is starting to come back to me. In the XLstart folder -
do I put something in there?

What is the personal xls file?

Thanks.
 
I figured out your suggestion. I created a new workbook and called it
Personal.xls and saved it to prog...XLstart and added

msgbox "testing"

to the ThisWorkbook.Open event.

Seems to work OK.

Now the real deal is that Excel is being opened by Sql Server Reporting
services. I have set some Reporting Services reports to open as Excel files
from a .Net app I wrote. The problem is that when users print out the Excel
reports -- they are printing out in landscape but need to be in Portrait
layout. I could add a macro button that the users can press before they
print, but I would rather identify the workbook as a reporting services
workbook and set the page layout to portrait seamlessly. I hope I can
identify the workbook on the application startup.
 

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