Get name of library for specific object vba

Viewed 239

I have looked everywhere and coulndt find a way to do this:

I have created an object with late binding as such:

set objNtWork = CreateObject("WScript.Network")

Now I want to add a reference in my project to the library.

How do I find the library name for that object?

1 Answers
Sub Alluding()

Dim o As Object

Set o = CreateObject("wscript.network")

Debug.Print TypeName(o)

End Sub

Returns

IWshNetwork2

So use as follows, Add the reference Windows Script Host Object Model:

Dim x As New WshNetwork

x.AddPrinterConnection "printername", "remotename"

So the following will show :

Sub Alluding()

Dim o As Object

Set o = CreateObject("wscript.network")

Debug.Print TypeName(o)


Dim w As New WshNetwork

Debug.Print TypeName(w)

End Sub

IWshNetwork2 IWshNetwork2

The same :)

Related