Save active Excel file to new location
Save active Excel file to new location
(OP)
Hello
I am trying to save an open (active) Excel file to a new location automatically.
I created a VBS program, which I wrote initially in VBA but I am loosing something when using VBS.
The SaveAs portion will not complete and gives no errors or warning.
I am temporarily using a MsgBox to see if I do get the file name.
The VBS program will be activated by PCM (A CMM programming language).
Any help with this is appreciated.
Regards.
I am trying to save an open (active) Excel file to a new location automatically.
I created a VBS program, which I wrote initially in VBA but I am loosing something when using VBS.
The SaveAs portion will not complete and gives no errors or warning.
I am temporarily using a MsgBox to see if I do get the file name.
The VBS program will be activated by PCM (A CMM programming language).
CODE --> vbs
Dim objXL, strMessage On Error Resume Next Set objXL = GetObject(,"Excel.Application") If Not TypeName(objXL) = "Empty" then 'strMessage = "Excel Running" MsgBox "The active workbook name is " & objXL.ActiveWorkbook.Name 'for testing, retrieves active workbook name ok objXL.SaveAs "C:\Users\Public\Documents\Zeiss\CALYPSO\workarea\results\Excel Files" & "\" & objXL.ActiveWorkbook.Name 'this line fails to save as Else MsgBox "No active Excel file open." End If
Any help with this is appreciated.
Regards.
RE: Save active Excel file to new location
CODE
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson
RE: Save active Excel file to new location
I found changing the string from:
CODE --> vbs
CODE --> vbs
I will test your suggestion for knowledge.
Rick Stanich
CMM Programming and Consulting
RE: Save active Excel file to new location
...Excel Files\" & sFileName & "\" & objXL.ActiveWorkbook.Name
Wouldn't you get 2 file names this way...? Unless sFileName is a sub-folder.
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson
RE: Save active Excel file to new location
My prior post of how the file SaveAs is working is not working...
The code has been modified with code from user: strongm (Thank you).
I appear to need assistance with "saving as". It has decided to no longer function.
I added a MsgBox for the "Phantom" choice (Current file in use) and the string is constructed properly, just no file is being saved as.
CODE --> VBS
Rick Stanich
CMM Programming and Consulting
RE: Save active Excel file to new location
...SaveAs Filename:="C:\...
---- Andy
"Hmm...they have the internet on computers now"--Homer Simpson
RE: Save active Excel file to new location
This is Line 27.
CODE --> VBS
CODE --> VBS
Rick Stanich
CMM Programming and Consulting