Please, do not post tangents about whether today's goal is good, bad, fast, slow, brilliant or stupid. I already had a bunch of those tangents
here. Strangely enough, that long winded discussion never mentioned createobject("
New:{1C3B4210-F441-11CE-B9EA-00
AA006B1A69
}") which I now believe might be a very useful construction.
My goal is to make vba code more portable by switching from early binding to late binding. I wanted to do this for ARBITRARY object types while keeping the object's methods and properties unchanged.
For instance let us say I want to switch the following code to late binding.
Dim x as dataobject ' reference to ms forms 2.0 object library which on my machine is c:\windows\syswow64\fm20.d
ll
set x = new dataobject
I
accidentally found a webpage that showed the following alternative.
dim x as object
Set x = CreateObject("New:{1C3B421
0-F441-11C
E-B9EA-00A
A006B1A69}
")
How can
intentionally find similar classids? For instance, can I transform the following
dim x as new SHDocVw.ShellWindows
ASKER
To replace MSForms.dataobject I search for "dataobject" and found just what I needed:
HKEY_CLASSES_ROOT\CLSID\{1
Class Reg_SZ Microsoft.Vbe.Interop.Form
Next, I wanted to replace < set x = New SHDocVw.ShellWindows > so I searched for "ShellWindows"
HKEY_CLASSES_ROOT\CLSID\{9
(default) REG_SZ Shellwindows
Appid Reg_SZ {9BA05972-F6A8-11CF-A442-0
That actually worked in the following (except SHDocVw.internetExplorer does not need a createobject because the For Each loop creates them.)
Open in new window
But, I still have one more question. What if I had been try to replace MsForms.Page? Search for "Page" gives me a dozen false positives before I finally got toClass Reg_SZ Microsoft.Vbe.Interop.Form
I recognized that as the correct key because I had previously seen the same structure for the DataObject. That is cheating, I want a methodology that finds an arbitrary object (without relying on previous success searching for a similar object).
Is there some methodology that will quickly get to the correct classId having just the library.class (E.G. SHDocVw.ShellWindows )?