e***@gmail.com
2015-01-05 23:05:49 UTC
I am trying to run this statement but not to know how to fix it :
oBook.ActiveWorkbook.Worksheets(Sheet.Name).SaveAs Chr(34) &Folder &"\" &FileName &"_" &Sheet.Name &".txt", 20
Here is the full script :
-------------------------
Dim oBook
Dim Sheet
Dim FileName
Set oBook = WScript.CreateObject("Excel.Application")
'oBook.Workbooks.Open("D:\shared\programs\vbscript\test.xls")
oBook.Workbooks.Open(Wscript.Arguments.Item(0) &"\" &Wscript.Arguments.Item(1))
FileName=(Wscript.Arguments.Item(1))
Folder=(Wscript.Arguments.Item(0))
MsgBox FileName
MsgBox Folder
oBook.Visible = false
oBook.DisplayAlerts = false
For Each Sheet In oBook.Worksheets
oBook.ActiveWorkbook.Worksheets(Sheet.Name).SaveAs Chr(34) &Folder &"\" &FileName &"_" &Sheet.Name &".txt", 20
MsgBox FileName+Sheet.Name
Next
oBook.Workbooks.Close
oBook.DisplayAlerts = True
oBook.Quit
oBook.ActiveWorkbook.Worksheets(Sheet.Name).SaveAs Chr(34) &Folder &"\" &FileName &"_" &Sheet.Name &".txt", 20
Here is the full script :
-------------------------
Dim oBook
Dim Sheet
Dim FileName
Set oBook = WScript.CreateObject("Excel.Application")
'oBook.Workbooks.Open("D:\shared\programs\vbscript\test.xls")
oBook.Workbooks.Open(Wscript.Arguments.Item(0) &"\" &Wscript.Arguments.Item(1))
FileName=(Wscript.Arguments.Item(1))
Folder=(Wscript.Arguments.Item(0))
MsgBox FileName
MsgBox Folder
oBook.Visible = false
oBook.DisplayAlerts = false
For Each Sheet In oBook.Worksheets
oBook.ActiveWorkbook.Worksheets(Sheet.Name).SaveAs Chr(34) &Folder &"\" &FileName &"_" &Sheet.Name &".txt", 20
MsgBox FileName+Sheet.Name
Next
oBook.Workbooks.Close
oBook.DisplayAlerts = True
oBook.Quit