09-12-2012, 10:34 AM
How to identify the object reference to the existing(already opened) Excel sheet in the Desktop and do"save as" of that file.I need to identify the existing(already opened) excel file in the desktop and do "save as" of that file in the designated folder. Please help me in getting VB Script code for this.
I have tried the below code, but its not working.
I am using Excel 2010.
I have tried the below code, but its not working.
I am using Excel 2010.
Code:
Dim fso, FolderPath, objExcel, strPathExcel
FolderPath = "c:\Excel_Reports"
strPathExcel = FolderPath&"abcd.xls"
' Get instance of FileSystemObject.
Set fso = CreateObject("Scripting.FileSystemObject")
Set objExcel = GetObject("","Excel.Application")
If not(fso.FolderExists(FolderPath)) then
fso.CreateFolder (FolderPath)
' Create a new folder with the FileSystemObject object.
End if
objExcel.ActiveWorkbook.saveas strPathExcel
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit