+ Reply to Thread
Results 1 to 7 of 7

References: CreateObject arguments for late binding

  1. #1
    Cheer
    Guest

    References: CreateObject arguments for late binding

    This is really a two part question.

    Part 1. Just for the sake of argument, suppose I, in developing an
    Excel add-in, included a few extraneous References in the VBE - i.e.,
    went to Tools/References and clicked on something I didn't really
    need. For example, I see I have the "Microsoft Windows Installer
    Object Library" checked, and I'm pretty sure I'm' not using anything
    from that library. Will Excel uncheck an unused reference? If not, is
    there an easy way to tell if that reference really needs to be
    included?

    Part 2. I would like to become a convert to late binding so I don't
    have to add a lot of references programmatically. Is there a resource
    somewhere that will tell me what to specify for the arguments for
    "CreateObject" for things like "Microsoft HTML Object Library,"
    "Microsoft XML, v3.0, " or "OLE Automation"? I''m most concerned with
    how to do "Microsoft XML, v3.0" as I'm getting errors when I try to
    install my add-in on machines other than my own. I understand I will
    no longer be able to use "Dim oHTTP As MSXML2.XMLHTTP30," but can
    someone give me the correct syntax for what should replace it? I know
    I have to start with "Dim oHTTP as object," but beyond that I'm a bit
    unsure. The below does not work:

    Dim obj As Object

    Set obj = CreateObject("MSXML2.XMLHTTP30")


    TIA for any help.


  2. #2
    Tom Ogilvy
    Guest

    Re: References: CreateObject arguments for late binding

    Excel does not release references if not used. Having references checked
    that you don't need invites problems if you distribute the app.

    I know nothing about Microsoft XML, but I came up with this which doesn't
    raise an error:

    Sub Testera()
    Dim ohttp As Object
    Set ohttp = CreateObject("MSXML2.XMLHTTP.3.0")
    Debug.Print ohttp.readyState
    Set ohttp = Nothing
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Cheer" <[email protected]> wrote in message
    news:[email protected]...
    > This is really a two part question.
    >
    > Part 1. Just for the sake of argument, suppose I, in developing an
    > Excel add-in, included a few extraneous References in the VBE - i.e.,
    > went to Tools/References and clicked on something I didn't really
    > need. For example, I see I have the "Microsoft Windows Installer
    > Object Library" checked, and I'm pretty sure I'm' not using anything
    > from that library. Will Excel uncheck an unused reference? If not, is
    > there an easy way to tell if that reference really needs to be
    > included?
    >
    > Part 2. I would like to become a convert to late binding so I don't
    > have to add a lot of references programmatically. Is there a resource
    > somewhere that will tell me what to specify for the arguments for
    > "CreateObject" for things like "Microsoft HTML Object Library,"
    > "Microsoft XML, v3.0, " or "OLE Automation"? I''m most concerned with
    > how to do "Microsoft XML, v3.0" as I'm getting errors when I try to
    > install my add-in on machines other than my own. I understand I will
    > no longer be able to use "Dim oHTTP As MSXML2.XMLHTTP30," but can
    > someone give me the correct syntax for what should replace it? I know
    > I have to start with "Dim oHTTP as object," but beyond that I'm a bit
    > unsure. The below does not work:
    >
    > Dim obj As Object
    >
    > Set obj = CreateObject("MSXML2.XMLHTTP30")
    >
    >
    > TIA for any help.
    >




  3. #3
    Cheer
    Guest

    Re: References: CreateObject arguments for late binding

    On Mon, 14 Feb 2005 09:08:28 -0500, "Tom Ogilvy" <[email protected]>
    wrote:

    >Excel does not release references if not used. Having references checked
    >that you don't need invites problems if you distribute the app.
    >
    >I know nothing about Microsoft XML, but I came up with this which doesn't
    >raise an error:
    >
    >Sub Testera()
    >Dim ohttp As Object
    >Set ohttp = CreateObject("MSXML2.XMLHTTP.3.0")
    >Debug.Print ohttp.readyState
    >Set ohttp = Nothing
    >End Sub



    Thanks, Tom. I suppose I'll just start hacking out references and see
    what breaks.

    Thank you too for the proper argument for CreateObject to load the XML
    v3.0 library. Knowing where to put those two dots made all the
    difference.

    Don't suppose you know how to do late binding on the Extensibility
    library and the HTML object library?


  4. #4
    Bob Phillips
    Guest

    Re: References: CreateObject arguments for late binding

    The extensibility library is simple, as you don't need to use Createobject,
    like so

    Dim VBComp As Object

    Set VBComp = ThisWorkbook.VBProject.vbcomponents("Module2")
    ThisWorkbook.VBProject.vbcomponents.Remove VBComp

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Cheer" <[email protected]> wrote in message
    news:[email protected]...
    > On Mon, 14 Feb 2005 09:08:28 -0500, "Tom Ogilvy" <[email protected]>
    > wrote:
    >
    > >Excel does not release references if not used. Having references checked
    > >that you don't need invites problems if you distribute the app.
    > >
    > >I know nothing about Microsoft XML, but I came up with this which doesn't
    > >raise an error:
    > >
    > >Sub Testera()
    > >Dim ohttp As Object
    > >Set ohttp = CreateObject("MSXML2.XMLHTTP.3.0")
    > >Debug.Print ohttp.readyState
    > >Set ohttp = Nothing
    > >End Sub

    >
    >
    > Thanks, Tom. I suppose I'll just start hacking out references and see
    > what breaks.
    >
    > Thank you too for the proper argument for CreateObject to load the XML
    > v3.0 library. Knowing where to put those two dots made all the
    > difference.
    >
    > Don't suppose you know how to do late binding on the Extensibility
    > library and the HTML object library?
    >




  5. #5
    Tom Ogilvy
    Guest

    Re: References: CreateObject arguments for late binding

    Bob answered for the extensibility library

    I did a google search on

    CreateObject MSXML2.XMLHTTP30

    If you create the reference, then look in the object browser, I assume the
    first part will be the library name (MSXML2 as an example). I picked the
    second from the object, but as you see, it required some alterations. I
    would probably search google on CreateObject and the library name alone.

    --
    Regards,
    Tom Ogilvy


    "Cheer" <[email protected]> wrote in message
    news:[email protected]...
    > On Mon, 14 Feb 2005 09:08:28 -0500, "Tom Ogilvy" <[email protected]>
    > wrote:
    >
    > >Excel does not release references if not used. Having references checked
    > >that you don't need invites problems if you distribute the app.
    > >
    > >I know nothing about Microsoft XML, but I came up with this which doesn't
    > >raise an error:
    > >
    > >Sub Testera()
    > >Dim ohttp As Object
    > >Set ohttp = CreateObject("MSXML2.XMLHTTP.3.0")
    > >Debug.Print ohttp.readyState
    > >Set ohttp = Nothing
    > >End Sub

    >
    >
    > Thanks, Tom. I suppose I'll just start hacking out references and see
    > what breaks.
    >
    > Thank you too for the proper argument for CreateObject to load the XML
    > v3.0 library. Knowing where to put those two dots made all the
    > difference.
    >
    > Don't suppose you know how to do late binding on the Extensibility
    > library and the HTML object library?
    >




  6. #6
    Bob Phillips
    Guest

    Re: References: CreateObject arguments for late binding

    The OP has made a good point though, so if anyone knows such a reference, I
    would also like to see it.

    Bob

    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > Bob answered for the extensibility library
    >
    > I did a google search on
    >
    > CreateObject MSXML2.XMLHTTP30
    >
    > If you create the reference, then look in the object browser, I assume the
    > first part will be the library name (MSXML2 as an example). I picked the
    > second from the object, but as you see, it required some alterations. I
    > would probably search google on CreateObject and the library name alone.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Cheer" <[email protected]> wrote in message
    > news:[email protected]...
    > > On Mon, 14 Feb 2005 09:08:28 -0500, "Tom Ogilvy" <[email protected]>
    > > wrote:
    > >
    > > >Excel does not release references if not used. Having references

    checked
    > > >that you don't need invites problems if you distribute the app.
    > > >
    > > >I know nothing about Microsoft XML, but I came up with this which

    doesn't
    > > >raise an error:
    > > >
    > > >Sub Testera()
    > > >Dim ohttp As Object
    > > >Set ohttp = CreateObject("MSXML2.XMLHTTP.3.0")
    > > >Debug.Print ohttp.readyState
    > > >Set ohttp = Nothing
    > > >End Sub

    > >
    > >
    > > Thanks, Tom. I suppose I'll just start hacking out references and see
    > > what breaks.
    > >
    > > Thank you too for the proper argument for CreateObject to load the XML
    > > v3.0 library. Knowing where to put those two dots made all the
    > > difference.
    > >
    > > Don't suppose you know how to do late binding on the Extensibility
    > > library and the HTML object library?
    > >

    >
    >




  7. #7
    Cheer
    Guest

    Re: References: CreateObject arguments for late binding

    Comments inline.

    On Mon, 14 Feb 2005 20:04:22 -0000, in
    microsoft.public.excel.programming "Bob Phillips"
    <[email protected]> wrote:

    >The extensibility library is simple, as you don't need to use Createobject,
    >like so
    >
    >Dim VBComp As Object
    >
    > Set VBComp = ThisWorkbook.VBProject.vbcomponents("Module2")
    > ThisWorkbook.VBProject.vbcomponents.Remove VBComp
    >


    Thanks, Bob. Nice illustration of adding/removing the object.

    On Mon, 14 Feb 2005 15:17:47 -0500, in
    microsoft.public.excel.programming "Tom Ogilvy" <[email protected]>
    wrote:

    >Bob answered for the extensibility library
    >
    >I did a google search on
    >
    >CreateObject MSXML2.XMLHTTP30
    >
    >If you create the reference, then look in the object browser, I assume the
    >first part will be the library name (MSXML2 as an example). I picked the
    >second from the object, but as you see, it required some alterations. I
    >would probably search google on CreateObject and the library name alone.


    Thank you too, Tom. I will separate the two pieces ("CreateObject" and
    the library name) when searching for the OLE Automation syntax.

    I envision a catalog of:

    Library Name
    A. How to invoke it using early binding
    1. How to programmatically add the reference
    B. How to invoke it using late binding

    Or better yet, a VBE tool that converts from early --> late,
    flawlessly. Oh, and it removes unneeded references. Would it hurt if
    it also made a good cheese danish?

    Thanks again to both of you for all of your help. You folks really are
    amazing.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1