PDA

View Full Version : [SOLVED] EXCEL FILE NOT SAVING IN VBS



satputenandk
09-03-2014, 06:00 AM
Dear Members,

I have below vbs code to open workbook run macro and then close. But I having problem with file saving. It is asking for save the copy of file. I am looking for command in vbs like thisworkbook.save is in excel.


Option Explicit
Dim xlApp, xlBook
Set xlApp = CreateObject("Excel.Application")
'~~> Change Path here
Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings\tg\Desktop\Nasik.xls", 0, True)
xlApp.Run "TrackingSheet"
xlApp.Save
xlBook.Close
xlApp.Quit

Set xlBook = Nothing
Set xlApp = Nothing

WScript.Echo "Finished."
WScript.Quit

Regards,
Nandkumar S.

mancubus
09-03-2014, 06:05 AM
xlBook.Save
and do not open the workbook read-only by TRUE argument




Dim xlApp, xlBook

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Documents and Settings\tg\Desktop\Nasik.xls")
xlApp.Run "TrackingSheet"
xlBook.Save
xlBook.Close
xlApp.Quit

WScript.Echo "Finished."
WScript.Quit

satputenandk
09-03-2014, 06:34 AM
Thank you very much. :)

mancubus
09-03-2014, 06:42 AM
you are welcome. :)

thanks for the feedback and marking the thread as solved.