How do I identify the batch conversion directory path in this XLS to XLSX VBScript? [closed]
I found a VBScript in stackexchange which should batch convert a folder of XLS files to XLSX but have been unsuccessful implementing it as an actual .vbs file. Seems I only need to identify my path somewhere in here bit I can't figure out where.
Here is @revosftw's VBScript post from stackexchange:
./convert-xls-xlsx.vbs {path to folder containing .xls files}
convert-xls-xlsx.vbs
:
Set args = WScript.Arguments
strPath = args(0)
strPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(strPath)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(strPath)
For Each objFile In objFolder.Files
fileName = objFile.Path
If (objFso.GetExtensionName(objFile.Path) = "xls") Then
Set objWorkbook = objExcel.Workbooks.Open(fileName)
saveFileName = Replace(fileName,".xls",".xlsx")
objWorkbook.SaveAs saveFileName,51
objWorkbook.Close()
objExcel.Application.DisplayAlerts = True
End If
Next
MsgBox "Finished conversion"
NOTE: Look out for spaces in the folder path, if your path has a space in between, put the path in quotes.
Assuming path to a folder full of xls files requiring conversion as "C:UsersDirectories with spacesDaily" I tried:
Set args = WScript.Arguments
strPath = args("C:UsersDirectories with spacesDaily")
'REST OF CODE UNCHANGED ...
and
Set args = WScript.Arguments
strPath = "C:UsersDirectories with spacesDaily"
'REST OF CODE UNCHANGED ...
and
./convert-xls-xlsx.vbs {"C:UsersDirectories with spacesDaily"}
Set args = WScript.Arguments
strPath = args(0)
'REST OF CODE UNCHANGED ...
Unfortunately every attempt has produced windows script host errors like:
line: 4
Char: 5
Error: Subscript out of range
Code: 800A0009
Source: Microsoft VBScript runtime error
vbscript
closed as off-topic by Ansgar Wiechers, Lankymart, Michael Dodd, TylerH, Paul Roub Jan 21 at 14:42
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Ansgar Wiechers, Lankymart, Michael Dodd, TylerH, Paul Roub
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I found a VBScript in stackexchange which should batch convert a folder of XLS files to XLSX but have been unsuccessful implementing it as an actual .vbs file. Seems I only need to identify my path somewhere in here bit I can't figure out where.
Here is @revosftw's VBScript post from stackexchange:
./convert-xls-xlsx.vbs {path to folder containing .xls files}
convert-xls-xlsx.vbs
:
Set args = WScript.Arguments
strPath = args(0)
strPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(strPath)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(strPath)
For Each objFile In objFolder.Files
fileName = objFile.Path
If (objFso.GetExtensionName(objFile.Path) = "xls") Then
Set objWorkbook = objExcel.Workbooks.Open(fileName)
saveFileName = Replace(fileName,".xls",".xlsx")
objWorkbook.SaveAs saveFileName,51
objWorkbook.Close()
objExcel.Application.DisplayAlerts = True
End If
Next
MsgBox "Finished conversion"
NOTE: Look out for spaces in the folder path, if your path has a space in between, put the path in quotes.
Assuming path to a folder full of xls files requiring conversion as "C:UsersDirectories with spacesDaily" I tried:
Set args = WScript.Arguments
strPath = args("C:UsersDirectories with spacesDaily")
'REST OF CODE UNCHANGED ...
and
Set args = WScript.Arguments
strPath = "C:UsersDirectories with spacesDaily"
'REST OF CODE UNCHANGED ...
and
./convert-xls-xlsx.vbs {"C:UsersDirectories with spacesDaily"}
Set args = WScript.Arguments
strPath = args(0)
'REST OF CODE UNCHANGED ...
Unfortunately every attempt has produced windows script host errors like:
line: 4
Char: 5
Error: Subscript out of range
Code: 800A0009
Source: Microsoft VBScript runtime error
vbscript
closed as off-topic by Ansgar Wiechers, Lankymart, Michael Dodd, TylerH, Paul Roub Jan 21 at 14:42
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Ansgar Wiechers, Lankymart, Michael Dodd, TylerH, Paul Roub
If this question can be reworded to fit the rules in the help center, please edit the question.
1
You don't need to change anything about the code. Just run the VBScript like this:./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
.
– Ansgar Wiechers
Jan 19 at 12:35
add a comment |
I found a VBScript in stackexchange which should batch convert a folder of XLS files to XLSX but have been unsuccessful implementing it as an actual .vbs file. Seems I only need to identify my path somewhere in here bit I can't figure out where.
Here is @revosftw's VBScript post from stackexchange:
./convert-xls-xlsx.vbs {path to folder containing .xls files}
convert-xls-xlsx.vbs
:
Set args = WScript.Arguments
strPath = args(0)
strPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(strPath)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(strPath)
For Each objFile In objFolder.Files
fileName = objFile.Path
If (objFso.GetExtensionName(objFile.Path) = "xls") Then
Set objWorkbook = objExcel.Workbooks.Open(fileName)
saveFileName = Replace(fileName,".xls",".xlsx")
objWorkbook.SaveAs saveFileName,51
objWorkbook.Close()
objExcel.Application.DisplayAlerts = True
End If
Next
MsgBox "Finished conversion"
NOTE: Look out for spaces in the folder path, if your path has a space in between, put the path in quotes.
Assuming path to a folder full of xls files requiring conversion as "C:UsersDirectories with spacesDaily" I tried:
Set args = WScript.Arguments
strPath = args("C:UsersDirectories with spacesDaily")
'REST OF CODE UNCHANGED ...
and
Set args = WScript.Arguments
strPath = "C:UsersDirectories with spacesDaily"
'REST OF CODE UNCHANGED ...
and
./convert-xls-xlsx.vbs {"C:UsersDirectories with spacesDaily"}
Set args = WScript.Arguments
strPath = args(0)
'REST OF CODE UNCHANGED ...
Unfortunately every attempt has produced windows script host errors like:
line: 4
Char: 5
Error: Subscript out of range
Code: 800A0009
Source: Microsoft VBScript runtime error
vbscript
I found a VBScript in stackexchange which should batch convert a folder of XLS files to XLSX but have been unsuccessful implementing it as an actual .vbs file. Seems I only need to identify my path somewhere in here bit I can't figure out where.
Here is @revosftw's VBScript post from stackexchange:
./convert-xls-xlsx.vbs {path to folder containing .xls files}
convert-xls-xlsx.vbs
:
Set args = WScript.Arguments
strPath = args(0)
strPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(strPath)
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFso.GetFolder(strPath)
For Each objFile In objFolder.Files
fileName = objFile.Path
If (objFso.GetExtensionName(objFile.Path) = "xls") Then
Set objWorkbook = objExcel.Workbooks.Open(fileName)
saveFileName = Replace(fileName,".xls",".xlsx")
objWorkbook.SaveAs saveFileName,51
objWorkbook.Close()
objExcel.Application.DisplayAlerts = True
End If
Next
MsgBox "Finished conversion"
NOTE: Look out for spaces in the folder path, if your path has a space in between, put the path in quotes.
Assuming path to a folder full of xls files requiring conversion as "C:UsersDirectories with spacesDaily" I tried:
Set args = WScript.Arguments
strPath = args("C:UsersDirectories with spacesDaily")
'REST OF CODE UNCHANGED ...
and
Set args = WScript.Arguments
strPath = "C:UsersDirectories with spacesDaily"
'REST OF CODE UNCHANGED ...
and
./convert-xls-xlsx.vbs {"C:UsersDirectories with spacesDaily"}
Set args = WScript.Arguments
strPath = args(0)
'REST OF CODE UNCHANGED ...
Unfortunately every attempt has produced windows script host errors like:
line: 4
Char: 5
Error: Subscript out of range
Code: 800A0009
Source: Microsoft VBScript runtime error
vbscript
vbscript
edited Jan 19 at 12:34
Ansgar Wiechers
142k13128185
142k13128185
asked Jan 19 at 3:20
StimmStimm
33
33
closed as off-topic by Ansgar Wiechers, Lankymart, Michael Dodd, TylerH, Paul Roub Jan 21 at 14:42
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Ansgar Wiechers, Lankymart, Michael Dodd, TylerH, Paul Roub
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by Ansgar Wiechers, Lankymart, Michael Dodd, TylerH, Paul Roub Jan 21 at 14:42
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Ansgar Wiechers, Lankymart, Michael Dodd, TylerH, Paul Roub
If this question can be reworded to fit the rules in the help center, please edit the question.
1
You don't need to change anything about the code. Just run the VBScript like this:./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
.
– Ansgar Wiechers
Jan 19 at 12:35
add a comment |
1
You don't need to change anything about the code. Just run the VBScript like this:./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
.
– Ansgar Wiechers
Jan 19 at 12:35
1
1
You don't need to change anything about the code. Just run the VBScript like this:
./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
.– Ansgar Wiechers
Jan 19 at 12:35
You don't need to change anything about the code. Just run the VBScript like this:
./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
.– Ansgar Wiechers
Jan 19 at 12:35
add a comment |
1 Answer
1
active
oldest
votes
Thanks @AnsgarWiechers - Your comment helped me figure out what I was doing wrong.
FIX AS FOLLOWS:
- Save the .vbs file to C:WindowsSystem32convert-xls-xlsx.vbs
- WindowsStart 'RUN' the VBScript with the following command:
- cscript ./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks @AnsgarWiechers - Your comment helped me figure out what I was doing wrong.
FIX AS FOLLOWS:
- Save the .vbs file to C:WindowsSystem32convert-xls-xlsx.vbs
- WindowsStart 'RUN' the VBScript with the following command:
- cscript ./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
add a comment |
Thanks @AnsgarWiechers - Your comment helped me figure out what I was doing wrong.
FIX AS FOLLOWS:
- Save the .vbs file to C:WindowsSystem32convert-xls-xlsx.vbs
- WindowsStart 'RUN' the VBScript with the following command:
- cscript ./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
add a comment |
Thanks @AnsgarWiechers - Your comment helped me figure out what I was doing wrong.
FIX AS FOLLOWS:
- Save the .vbs file to C:WindowsSystem32convert-xls-xlsx.vbs
- WindowsStart 'RUN' the VBScript with the following command:
- cscript ./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
Thanks @AnsgarWiechers - Your comment helped me figure out what I was doing wrong.
FIX AS FOLLOWS:
- Save the .vbs file to C:WindowsSystem32convert-xls-xlsx.vbs
- WindowsStart 'RUN' the VBScript with the following command:
- cscript ./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
answered Jan 19 at 18:19
StimmStimm
33
33
add a comment |
add a comment |
1
You don't need to change anything about the code. Just run the VBScript like this:
./convert-xls-xlsx.vbs "C:UsersDirectories with spacesDaily"
.– Ansgar Wiechers
Jan 19 at 12:35