For DOS batch file

Sebastian42

New Member
Joined
Sep 22, 2010
Messages
47
What VBS script would cause an open Excel sheet to be saved ?

[I'm confused by the VBA in the 'title' : Excel Questions All Excel/VBA questions]
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
There's not usually any difficulty saving a file ... hit the save button ... :confused:
 
Upvote 0
I agree it is not difficult to save by Control S, but it is one more step which I have to do routinely, that I'd like to be automated, along with closing Excel and backing up the saved file. The latter two steps are already taken care of in a (DOS) batch file, and if it is possible, I'd like to include the Saving as well. I have been given VBS script for it, but I don't know how to incorporate that into a DOS Batch File. It's been suggested that it is an API rather than an Excel issue, but I have not found any relevant API forum that I can ask.
 
Upvote 0
Just to continue from the cross post at OzGrid...

"My" code was simply a demonstration of what could be done... not a complete working solution. Plus, the 'language' (as such) is VB script not a DOS batch file.

Copying that code into a batch file will result in errors simply because it is being processed as a batch file and not a VBS file. GetObject, for example, is not a valid internal (external, operable program or batch file) command in DOS.

As regards approaching API experts for your solution, I would have been quite willing to help you to develop an VBS/API based solution if that would have been a suitable approach but your emphasis on 'my' code not working was a little off-putting.

Just out of interest, I am a C++/C#, Assembler programmer, oh, and I've used that horrible Visual Basic extensively in all versions from Visual Studio 2008 all the way back to Visual Basic Version 1.0 in 1991 - so I have a reasonable knowedge of the Windows API). I hang around the Ozgrid board to gain an appreciation of the Excel user functionality like formulas and stuff like that.
 
Upvote 0
Cytop
I am sorry you were put off by the factual statement that your code did not achieve my aim in the environment for which I want it. I seem to be an expert at unintentionally getting on the wrong side of the moderators/members (?) of these two/three excel forums.

By the way, I have tried to find the warnings about cross-posting in a signature, but am at a loss as to how to go about that.

I thought forums were about helping people who do not yet know, but here I feel penalised for my ignorance. I do not know if a VBS/API solution is what I need.

In a different matter I have been able to run VBS script in a DOS batch file quite successfully, and was hoping that might be the case for SAVING AN OPEN EXCEL WORKBOOK too. I would rather incorporate whatever solution is available in a DOS batch file, than to start over and have to do those three things (save, close, backup) in a different way that I am not familar with.

If your tolerance has not yet been exhausted, I'd appreciate your VBS/API solution to try in a batch file.
 
Upvote 0
The 'issues' about cross posting are explained more eloquently here that any thing I could write...

Forums are about helping - and learning. I learn a lot about the 'visible' (user interface wise) aspects of Excel from the boards. In return I share what I do know about the coding aspects.

I don't have a ready made solution to your problem. It's not something I have done in that exact context. But I do know how to find a Window, find it's child windows and then find a command button (or menu item) in that window and execute the click event for that control. but I'm not sure it's the most practical solution to your issue as it's a lot of work for relatively little return.

Basically, it's an overcomplicated solution for a simple problem; What happens in 6 months or a year? Applications get upgraded... Class names might change, or even the menu caption changes. Perhaps Sebastian42/SmileyMan gets promoted...
 
Upvote 0
It does look quite daunting, and maybe not worth the trouble. Thank you for your effort.
p.s. promotion is not likely to affect my asthma, the recording and charting of which (of peakflow anyway) is the content of the SS whose use I was trying to 'minimise'.
 
Upvote 0
By the way, I have tried to find the warnings about cross-posting in a signature, but am at a loss as to how to go about that.
We allow cross-posting, we just ask that you extend the courtesy to include a link to the other threads you have on the topic in other forums so that others can see what has already been done on the subject.

Our policy on cross-posting can be seen in rule #24 here:
24. Cross-posting is the term we use when a person has posted the same question to multiple online forums. While there is nothing actually "wrong" with this, it is asked that you at least mention that the question has been posted elsewhere, including a link to the thread on the other forum. There are many people who post at several different forums; threads are cross-posted without stating it are easily identified and pointed out as such.
  1. Read: http://www.excelguru.ca/node/7
 
Upvote 0
FYI, you cannot directly use API calls from VBS anyway.
However, assuming you know the name and path of the file, you can simply use GetObject to grab a reference to it, and from that you can save it, save a copy of it elsewhere as a backup and/or generally do what you like.
 
Upvote 0

Forum statistics

Threads
1,215,381
Messages
6,124,615
Members
449,175
Latest member
Anniewonder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top