ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running Excel as a batch job AND in the background (https://www.excelbanter.com/excel-programming/275694-re-running-excel-batch-job-background.html)

GB[_3_]

Running Excel as a batch job AND in the background
 

"Robert Stober" wrote in message
...
Thank Andy! This worked for me! I edited your command as follows:

Set xlObj = CreateObject("Excel.application")
xlObj.Workbooks.Open "H:\licana\licuser\orders\22345585\template.xl s"
xlObj.Quit

Can I use an environemnt variable inside VB? I want the order number
("22345585" in this case) to be contained in an enviroment variable. This

is
what I do inside aVBA template:

Dim orderNum As Long
Dim fPath As String
orderNum = Environ("orderNum")
fpath = "H:\licana\licuser\orders\" & orderNum & "\template.xls"

Can I do this in VB? My book doesn't mention enviroment variables...


How about saving it in the registry instead? - use SaveSetting to store and
getsetting to get it back.

HTH

Geoff



Thanks again,

Robert



"Andy Wiggins" wrote in message
...
Try something like this. Save it in a standard text file with a .VBS
extention.
This one creates an Excel object, opens a workbook, sets a value, runs a

VBA
routine, then tides up and closes down.

Set xlObj = CreateObject("Excel.application")
xlObj.Workbooks.Open "C:\Byg\textfile\TextFileReformat.xls"
xlObj.Range("NoOfCharsPerLine").Value = 50
xlObj.Run "ReadFromTextFile"
xlObj.ActiveWorkbook.Saved = True
xlObj.ActiveWindow.Close
xlObj.Quit

--
Regards
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-
"Robert Stober" wrote in message
...
Hi,

I'm trying to get my Excel template to run in the background as a

batch
job.
I have no problem running it as a batch job, but I don't want Excel to

show
up on the screen of the execution host. So I'm trying to use the

/embedded
switch.

On the command line: "C:\Program Files\Microsoft

Office\Office\EXCEL.EXE"
/embedded template.xls

I've also tried setting FTYPE on the command line:

Excel.Sheet.8="C:\program Files\Microsoft Office\Office\Excel.EXE"

/embedded
start template.xls

Either way, the dialog (not the usual one) pops up to verify whether I

want
to allow Macros, the Excel.exe process is started, and exits as it

should
(due to Application.Quit).

But in the end, the files that should be created aren't there. It

works
fine
if I don't specify "/embedded". There's no sign of them anywhere on my
computer...

I feel that I could solve this if I could "see" what's going on. I

have
no
visibility into the process. Is there a way to write a log file?

Thank you very much,

Robert Stober










All times are GMT +1. The time now is 12:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com