How to code VBA: Auto open workbook and run macro

M

March

Hello all,

I need to create excel vba in order to auto open workbook in specific time.
I setup Windows Scheduled Tasks to open excel everyday for example at 2:00
pm. I need the workbook to open at this time too and run macros. After the
job done, I want to send email to my email to say that job is finished.

I don't know what to start. Please give me suggestion.


March
 
B

Barb Reinhardt

In the VBE, use a Workbook_Open macro to define what you want done when the
workbook is opened. Once the workbook is created, you can use your Windows
Scheduled tasks to open it at 2 PM and it should run.

Do you have specific questions on how to code something?
 
M

March

Thank you to reply.

My question is between

Private Sub Workbook_Open()


End Sub

My understanding now is when I use Workbook_Open( ) in my workbook,
everytime when I open excel this workbook should be auto opened. Am I right?
If yes, I don't want the workbook open all time I open excel. I need it to
open only at 2:00 pm. So this point I don't know how to tell excel to open
the file at the fixed time.

I am not sure that "How excel knows which file should be opened????"


March
 
J

John Google

Rather than open excel at 2pm, open the workbook

Run c:\<path to your WB>\My Workbook.xls

Excel should start and then open the workbook. At this point the
Workbook_Open() event will execute.

Note however, unless you have security level set to low (See Tools /
Marco / Security / Security Level Tab for details), you will get a
prompt asking if you want to disable macros. This would have to be
clicked before the event fires.

JohnGoogle
 

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

Top