SBendBuckeye
Programmer
A gentleman named Ben O'Hara was kind enough to post some VBScript code to help automate an Access upgrade from Access97 to Access2000. His response was to my post on the Access VBA forum.
Here is the working code which I run by double clicking the file named Convert.vbs in the Windows file explorer. I have not used VBScript before but have used Access VBA extensively.
Some questions follow the code.
************************** BEGIN CODE ********************
Option Explicit
Dim WshShell
Dim FSO
Dim strFromDir
Dim strConvertDir
Dim Folder
Dim File
Set WshShell = WScript.CreateObject("WScript.Shell"
Set FSO = WScript.CreateObject("Scripting.FileSystemObject"
'strFromDir="C:\databases\"
'strFromDir="B:\References Project\Test\"
strFromDir="B:\Refere~1\Test\"
strConvertDir=strFromDir & "Convert\"
set Folder= FSO.GetFolder(strFromDir)
for each File in Folder.Files
WSHShell.Run "C:\Progra~1\Micros~3\Office\Msaccess.exe " & File.Path & " /convert " & strConvertdir & file.name
next
wscript.quit
************************** END CODE **********************
1. This attemps to convert every file in the directory. Can I filter for the extension mdb?
2. Is there a function to convert Long File Names with embedded spaces into the old style FileNa~x notation so the code doesn't break?
3. How do I handle number 2 above for File names with an embedded space?
4. Can I invoce the vbs file from a bat file or from Access? If so, how do I do that?
5. How do I pass parameters into my vbs file?
Any help, suggestions or code samples would be greatly appreciated! Have a great daY!
Here is the working code which I run by double clicking the file named Convert.vbs in the Windows file explorer. I have not used VBScript before but have used Access VBA extensively.
Some questions follow the code.
************************** BEGIN CODE ********************
Option Explicit
Dim WshShell
Dim FSO
Dim strFromDir
Dim strConvertDir
Dim Folder
Dim File
Set WshShell = WScript.CreateObject("WScript.Shell"
Set FSO = WScript.CreateObject("Scripting.FileSystemObject"
'strFromDir="C:\databases\"
'strFromDir="B:\References Project\Test\"
strFromDir="B:\Refere~1\Test\"
strConvertDir=strFromDir & "Convert\"
set Folder= FSO.GetFolder(strFromDir)
for each File in Folder.Files
WSHShell.Run "C:\Progra~1\Micros~3\Office\Msaccess.exe " & File.Path & " /convert " & strConvertdir & file.name
next
wscript.quit
************************** END CODE **********************
1. This attemps to convert every file in the directory. Can I filter for the extension mdb?
2. Is there a function to convert Long File Names with embedded spaces into the old style FileNa~x notation so the code doesn't break?
3. How do I handle number 2 above for File names with an embedded space?
4. Can I invoce the vbs file from a bat file or from Access? If so, how do I do that?
5. How do I pass parameters into my vbs file?
Any help, suggestions or code samples would be greatly appreciated! Have a great daY!