You need to convert the given CLSID into a ProgID and then create the object subsequently. There are a few OLE APIs which do the same. See the following code.
___
[tt]
Option Explicit
Private Declare Function ProgIDFromCLSID Lib "ole32" (pCLSID As Any, lpszProgID As Long) As Long
Private Declare Function CLSIDFromString Lib "ole32" (ByVal lpszProgID As Long, pCLSID As Any) As Long
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenW" (ByVal lpString As Long) As Long
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyW" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
Function CLSIDToProgID(ByVal CLSID As String) As String
Dim guid(15) As Byte, pResult As Long
CLSIDFromString StrPtr(CLSID), guid(0)
ProgIDFromCLSID guid(0), pResult
CLSIDToProgID = Space$(lstrlen(pResult))
lstrcpy ByVal StrPtr(CLSIDToProgID), pResult
End Function
Private Sub Form_Load()
Dim CLSID As String, ProgID As String, obj As Object
CLSID = "{72C24DD5-D70A-438B-8A42-98424B88AFB8}" 'WScript.Shell
ProgID = CLSIDToProgID(CLSID)
Set obj = CreateObject(ProgID)
MsgBox obj.currentdirectory
Unload Me
End Sub[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.