Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running an Excel macro from XP Pro platform .bat file

Status
Not open for further replies.
May 5, 2004
29
GB
Hi Folks,

I was wondering whether this was possible?
Just a bog standard .xls 2003 flavour sheet with basic
vba module setting the cell A1 to "hi world" in order to
test.

I would like to run this workbook welcome.xls from a batch file and to be able to have this batch scheduled - should be possible, is it?

Many Thanks
 
You could have subroutine kick off from then Workbook_Open event. Just place it in the ThisWorkbook object.

Code:
[i]ThisWorkbook[/i]
Private Sub Workbook_Open()
    'whatever
End Sub
 
...yes I think that Workbook_Open() works, but suppose this scenario:
The macro is accessing a 2 million row SQL Server table which in itself joins another 500k table, so it runs and produces the report. What happens when a user then sees the report and opens it in the ordinary way? With this Workbook_Open() statement which runs script upon opening the workbook would the report automatically run again? It seems so to me it would.

Regards
 
It certainly would. In that case, you might want to try something with VBScript?
It can access the Excel Object Model and really do everything from the script. I'm uncertain, but fairly confident that VBA subroutines can be called from VBS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top