I have this VBScript that works just fine in the local html page under MS Windows 7 32bit because it referenced to MS Windows Text-to-Speech package is 32 bits.
Dim sapi
Set sapi=CreateObject("sapi.spvoice")
For Each Voice In sapi.getvoices
I = I + 1
msgbox "" & (I - 1) & " - " & Voice.GetDescription
Next
The problem I am facing is that the same package under MS Windows 7 64 is installed under C:\Windows\SysWOW64\
So it is visible if you start this console
C:\Windows\SysWOW64\Speech\SpeechUX\sapi.cpl
And it has impact to the VBScript above because it uses 64bit SAPI and not 32 SAPI.
So I would like to find a correct way/code to use
Set sapi=CreateObject("sapi.spvoice")
for WIN32 objects. So it is kinda how to create ActiveX Win32 under Windows 64 bit in VBScript of the HTML page.
How it can be done?
It wasn't clear when you first posed the question that the VBScript was being run inside an Internet Browser (assuming Internet Explorer as built-in support for VBScript in other browsers is none existent).
In the scenario where an Internet Browser is being used the same rules when dealing with multiple architectures applies. Instead of the client being the scripting host (cscript
or wscript
) the Internet Browser takes on this role.
We thus have to make sure we are using the correct architecture version of the browser.
%ProgramFiles%\Internet Explorer\iexplore.exe
%ProgramFiles(x86)%\Internet Explorer\iexplore.exe
If the wrong architecture version of the Internet Browser is executed the CreateObject()
function will look in the wrong part of the registry for the corresponding ProgId
(sapi.spvoice
), which can lead to errors like this:
Error: ActiveX component can't create object
Code: 800A01AD
Source: Microsoft VBScript Runtime Error
This is more common with applications that are solely 32 bit as the 64 bit part of the registry will never contain the corresponding registered COM components.
You may sometimes find that for whatever reason you have to register the COM DLL manually which can also be confusing for some. It's important to understand the differences.
%SystemRoot%\System32\regsvr32.exe
%SystemRoot%\SysWOW64\regsvr32.exe
It's also important to note that this only applies to 64 bit Windows Operating Systems as 32 bit ones will just contain the 64 bit equivalent locations. Both %ProgramFiles(x86)
and SysWOW64
are locations specific to 64 bit Windows Operating Systems only.