Can I invoke excel automatically from .bat or other means so that.

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

Guest

I would like to automate updating of a number of excel spreadsheets. Is
there any way to invoke excel without opening excel or a excel spreadsheet.
 
Yup... Place this line in a batch file

"C:\Program Files\Microsoft Office\Office\excel.exe"

You have to assume a standard install of excel though...

HTH
 
Just a note that I did not mention. You do need the "". This is the only
difference from invoking Excel from a command prompt. The same as you need ""
for copy or any other function that uses a directory withg blank charachters
in the path...

HTH
 
I would like to open a specific spreadsheet xxx.xls and process macros in the
spreadsheet without any human intervention.
 
Well,

If I wanted to open a specific spreadsheet and execute a macro without
intervention what else might I do?
 
Try creating a file with VBS extention.
This VBScript file is basically a latebound VBA file
and coding is almost similar to VBA.

Please note that many administrators will disable VBS files from running
on their networks.



'Code for OpenBook.vbs
Dim xlApp
Dim xlWkb
Const cEXIT = True

Set xlApp = CreateObject("excel.application")
Set xlWkb = xlApp.Workbooks.Open("c:\book.xls")
xlWkb.RunAutoMacros 1 'xlautoopen
xlApp.Run "book.xls!MacroA"
xlApp.Run "book.xls!MacroB"

'now either make Excel visible or close it
If cEXIT Then
xlWkb.Close 0
xlApp.Quit
Set xlWkb = Nothing
Set xlApp = Nothing
Else
xlApp.Visible = True
End If

hope this gives you a leg up. :)





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


rmkbrj wrote :
 
Thanks, I'll Try that.

keepITcool said:
Try creating a file with VBS extention.
This VBScript file is basically a latebound VBA file
and coding is almost similar to VBA.

Please note that many administrators will disable VBS files from running
on their networks.



'Code for OpenBook.vbs
Dim xlApp
Dim xlWkb
Const cEXIT = True

Set xlApp = CreateObject("excel.application")
Set xlWkb = xlApp.Workbooks.Open("c:\book.xls")
xlWkb.RunAutoMacros 1 'xlautoopen
xlApp.Run "book.xls!MacroA"
xlApp.Run "book.xls!MacroB"

'now either make Excel visible or close it
If cEXIT Then
xlWkb.Close 0
xlApp.Quit
Set xlWkb = Nothing
Set xlApp = Nothing
Else
xlApp.Visible = True
End If

hope this gives you a leg up. :)





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


rmkbrj wrote :
 
keepITcool,

I tried the script and it certainly is closer to what I want but I can't
seem to get the worksheet closed (It stays open and a EXCEL process continues
running) If it try to open the xls file after running the script it says
it's still open..... I tried xlapp.close which didn't fly and it also
disliked the xlapp.visable = true. By the way I'm using Excel 2000. It did,
however, open the spreadsheet and execute what I expected. Closing it up,
without intervention, is the issue now.
 
Hi,

I just wanted to point you to the VBScript (which does work properly
with a simple workbook and a few simple macros.)

Try google news on this group : search for "close quit" and
you'll find plenty of advice, though sometimes it can be difficult to
find the culprit. (most likely


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


rmkbrj wrote :
 
Thanks, I'll look there.

keepITcool said:
Hi,

I just wanted to point you to the VBScript (which does work properly
with a simple workbook and a few simple macros.)

Try google news on this group : search for "close quit" and
you'll find plenty of advice, though sometimes it can be difficult to
find the culprit. (most likely


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


rmkbrj wrote :
 
keepITcool said:
Hi,

I just wanted to point you to the VBScript (which does work properly
with a simple workbook and a few simple macros.)

Try google news on this group : search for "close quit" and
you'll find plenty of advice, though sometimes it can be difficult to
find the culprit. (most likely


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


rmkbrj wrote :
 
You can launch excel through a batch file

"C:\Program files\microsoft office\office\excel.exe xcel_filename.xls"
the macro that runs automatically when the file is opened will execute. the
macro must specifically close the file prior to exiting excel.

you would need to have either a excel file with a macro to run all the
updates or run each file from the batch file.
Jerry
 

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