jphilippa
-
Total Posts
:
3
- Scores: 0
-
Reward points
:
0
- Joined: 10/4/2010
-
Status: offline
|
VBS in a DOS batch file
Tuesday, October 05, 2010 1:55 AM
( permalink)
I do not understand VBS but was given VBS code which I have used successfully in a DOS batch file. That success makes me think that maybe I can do it again in another context. I've been given code as a result of saying that I wanted to save an open Excel spread sheet by means of a DOS batch file. The code does not work by itself in the batchfile, and is so dissimilar from the first example which I mentioned, that I can get no clues from the first for applying to the second. Can someone here give me the 'missing links' to make the following code effective in a DOS batchfile ? : Dim x set x = getobject(, "Excel.application") 'msgbox x.caption x.SaveAs "C:\FileLocation\WorkBookName.XLS" x.Application.Quit Set x= Nothing A second suggestion was to 'capture' the macro created for/when saving the spreadsheet. That content is much simpler, but again, I don't know how to make it effective in a DOS batchfile.
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
Re:VBS in a DOS batch file
Tuesday, October 05, 2010 7:37 AM
( permalink)
Neither of those would be doable in a dos batch file.
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
Re:VBS in a DOS batch file
Tuesday, October 05, 2010 7:39 AM
( permalink)
The closest that you might be able to get would be to put a macro in the workbook that would print the sheet you want then close excel. Then it would be possible to call the excel file and pass in a command line parameter that caused it to run that macro.
|
|
|
|
jphilippa
-
Total Posts
:
3
- Scores: 0
-
Reward points
:
0
- Joined: 10/4/2010
-
Status: offline
|
Re:VBS in a DOS batch file
Tuesday, October 05, 2010 10:31 AM
( permalink)
I don't want a sheet printed - I just want to save the opened and edited excel sheet.
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: offline
|
Re:VBS in a DOS batch file
Tuesday, October 05, 2010 11:56 PM
( permalink)
Sorry, that isn't possible in DOS. To do that you would need to use the COM API that Excel exposes and DOS has no way to access that. Why not just write a VBScript and have your batch file call that?
|
|
|
|
jphilippa
-
Total Posts
:
3
- Scores: 0
-
Reward points
:
0
- Joined: 10/4/2010
-
Status: offline
|
Re:VBS in a DOS batch file
Wednesday, October 06, 2010 12:51 AM
( permalink)
That is precisely what I have done, with much assistance from an Excel forum and it works. I had many vicissitudes in the excel forum and it seemed maybe I was asking the wrong people - that is when I sought and found this forum. But then my fortunes took a turn for the better, and someone at MrExcel took me through the process step by step. Presto, DONE. Thank you.
|
|
|
|