1

Shouldn't you be able to implement the ADOX library via VBScript? The code below runs perfect via Access 2010 on Windows 7, Office 2010 32-bit, but doesn't via a VBScript. Isn't ADOX just another COM Object like say FileSystemObject?

Dim objADOX

Set objADOX = CreateObject("ADOX.Catalog")
objADOX.ActiveConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Zamdrist\Desktop\Work\Scripts\Shell.accdb"
MsgBox objADOX.Tables.Count

Sorry, I should point out, VBScript complains that the provider does not exist. Odd because I do in fact have Access 2010 installed.

Steve
  • 549
  • 6
  • 21
  • 3
    Yep, ADOX should work fine. If it didn't, you'd get an error on the `CreateObject()` line. Your error is happening on the `ActiveConnection` line. Are you on 64-bit Windows 7? If so, are you using the 64-bit version of `WSCRIPT.EXE`? You'll probably need to use the 32-bit version of `WSCRIPT` to access the 32-bit OLEDB drivers. – Bond Jul 10 '14 at 04:02
  • 2
    The 32-bit versions of `wscript.exe` and `cscript.exe` can be found in `C:\Windows\SysWOW64`. – Ansgar Wiechers Jul 10 '14 at 06:42
  • Bond, if you want to answer this I'll mark is as answered. Thanks! – Steve Jul 23 '14 at 12:18

1 Answers1

2

This is not meant as an answer just simply as a tip that has helped me tremendously. I am constantly working with providers that only work with 32 bit so i always add the attached code to all of my scripts. This way it doesn't matter if the machine that is executing the code is 32 or 64 bit.

'Check for 64 bit and run as 32 bit if needed.
'On error resume next

Set oFso = CreateObject("Scripting.FileSystemObject")
Set oWs = CreateObject("WScript.Shell")

windowsdir = oWs.ExpandEnvironmentStrings("%windir%")

If InStr(LCase(WScript.FullName), windowsdir & "\system32\") And oFso.FolderExists(windowsdir & "\SysWow64") Then       
    oWs.Run windowsdir & "\SysWow64\WScript.exe """ & WScript.ScriptFullName & """"
    WScript.Quit
End If

'code to run as 32 bit
Sean Wessell
  • 3,490
  • 1
  • 12
  • 20