Registered COM DLL works in VBA but not in VBScript -


i have created basic com dll atl on vs2012. it's called testcom.dll , has 1 class called csimpleobj. csimpleobj has 1 method called addvalues adds 2 values.

i've registered dll windows 7 64-bit. in vba, manually add reference dll , below code works properly

dim obj new testcomlib.simpleobj msgbox obj.addvalues(1,2) 

and give message number 3.

now if run vbs includes:

dim obj set obj = createobject("testcomlib.simpleobj") 

it gives error , not able create object. if use "excel.application" progid (as example) createobject method, works fine.

i think there issue registering dll. i've checked registry, , keys com , type library there.

what should do?

there 3 basic requirements com server usable vbscript:

  • you need implement idispatch late binding supported. not problem atl, implements default when use wizards.

  • your registry script (.rgs) must write progid registry. notable didn't report finding (look hkcr\testcomlib.simpleobj regedit.exe verify). clsid subkey must match clsid in registry com can find dll. atl simple object wizard has trap, fills in fields when type short name. except progid field. easy forget.

  • on 64-bit version of windows, you'll execute 64-bit version of cscript.exe default. not able find 32-bit com server. you'll need either build x64 version of server or you'll need use 32-bit version of cscript.exe, located in c:\windows\syswow64. not problem vba since tends used 32-bit version of office.

the sysinternals' process monitor utility useful diagnose these kind of problems. you'll see cscript.exe searching registry keys server registered. , not finding them, not explicit enough actual error message got.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -