VBA---Tools--References automatic

Discussion in 'Microsoft Excel Programming' started by Denys, Oct 3, 2007.

  1. Denys

    Denys Guest

    Good day everyone,

    Is it possible through VBA in the Workbook open to add an instruction
    in order to make sure that the "Microsoft Forms 2.0 Object Library" is
    entered..

    In the VBA window, you must click on Tools, then References and then
    click on the "Microsoft Forms 2.0 Object Library"

    I'd like this to be automated..... I tried:

    Private Sub Workbook_Open()
    VB(References("Microsoft Forms 2.0 Object Library")).Installed
    = True

    Does not work... Also played around with the paranthesis.... Did not
    work either...

    If someone knows, I would appreciate.

    Thanks for your time

    Denys
     
    Denys, Oct 3, 2007
    #1
    1. Advertisements

  2. Denys

    Bob Phillips Guest

    http://support.microsoft.com/default.aspx?kbid=213529
    XL2000: How to Programmatically Create a Reference

    --
    HTH

    Bob

    (there's no email, no snail mail, but somewhere should be gmail in my addy)

    "Denys" <> wrote in message
    news:...
    > Good day everyone,
    >
    > Is it possible through VBA in the Workbook open to add an instruction
    > in order to make sure that the "Microsoft Forms 2.0 Object Library" is
    > entered..
    >
    > In the VBA window, you must click on Tools, then References and then
    > click on the "Microsoft Forms 2.0 Object Library"
    >
    > I'd like this to be automated..... I tried:
    >
    > Private Sub Workbook_Open()
    > VB(References("Microsoft Forms 2.0 Object Library")).Installed
    > = True
    >
    > Does not work... Also played around with the paranthesis.... Did not
    > work either...
    >
    > If someone knows, I would appreciate.
    >
    > Thanks for your time
    >
    > Denys
    >
     
    Bob Phillips, Oct 3, 2007
    #2
    1. Advertisements

  3. Watch for the word wrap -

    With ThisWorkbook.VBProject.References
    .AddFromFile ("C:\WINDOWS\SYSTEM\MSForms.TWD")
    End with

    'Cant be sure if that's the correct ref though...


    --
    ---
    HTH
    Roger
    Shaftesbury (UK)
    (Excel 2003, Win XP/SP2)

    "Denys" <> wrote in message
    news:...
    > Good day everyone,
    >
    > Is it possible through VBA in the Workbook open to add an instruction
    > in order to make sure that the "Microsoft Forms 2.0 Object Library" is
    > entered..
    >
    > In the VBA window, you must click on Tools, then References and then
    > click on the "Microsoft Forms 2.0 Object Library"
    >
    > I'd like this to be automated..... I tried:
    >
    > Private Sub Workbook_Open()
    > VB(References("Microsoft Forms 2.0 Object Library")).Installed
    > = True
    >
    > Does not work... Also played around with the paranthesis.... Did not
    > work either...
    >
    > If someone knows, I would appreciate.
    >
    > Thanks for your time
    >
    > Denys
    >
     
    Roger Whitehead, Oct 3, 2007
    #3
  4. Denys

    Peter T Guest

    One more, the example is generic so adapt to add the reference to
    ThisWorkbook in the open event.

    Sub test()
    Dim wb as Workbook
    Dim objRef As Object ' Reference


    Set wb = Workbooks("Book5") ' change

    With wb.VBProject.References
    On Error Resume Next
    Set objRef = .Item("MSForms")
    On Error GoTo 0
    If objRef Is Nothing Then
    Set objRef = .AddFromGuid("{0D452EE1-E08F-101A-852E-02608C4D0BB4}", 0, 0)
    End If
    End With

    ' MsgBox objRef.Name
    End Sub

    I can't think why you would ever need to do this as the reference is saved
    with the workbook. If you have programmatically added code to some other
    workbook, then add the reference at the same time.

    Regards,
    Peter T

    "Denys" <> wrote in message
    news:...
    > Good day everyone,
    >
    > Is it possible through VBA in the Workbook open to add an instruction
    > in order to make sure that the "Microsoft Forms 2.0 Object Library" is
    > entered..
    >
    > In the VBA window, you must click on Tools, then References and then
    > click on the "Microsoft Forms 2.0 Object Library"
    >
    > I'd like this to be automated..... I tried:
    >
    > Private Sub Workbook_Open()
    > VB(References("Microsoft Forms 2.0 Object Library")).Installed
    > = True
    >
    > Does not work... Also played around with the paranthesis.... Did not
    > work either...
    >
    > If someone knows, I would appreciate.
    >
    > Thanks for your time
    >
    > Denys
    >
     
    Peter T, Oct 3, 2007
    #4
  5. Denys

    Denys Guest

    Re: VBA---Tools--References automatic

    Good afternoon everyone,

    Thank you very much for your time. Peter T, your solution is perfect
    works like a charm !!!!

    Have a nice day ..

    Denys
     
    Denys, Oct 3, 2007
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jamie Carper

    References.Remove References(1) DOES NOT WORK for "MISSING:" Refs

    Jamie Carper, May 27, 2004, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    562
    Jamie Carper
    May 27, 2004
  2. L Mehl

    Tools | References - information about references

    L Mehl, Jul 4, 2004, in forum: Microsoft Excel Programming
    Replies:
    7
    Views:
    354
    L Mehl
    Jul 4, 2004
  3. Guest

    Tools...References shows "MISSING:" in front of 2 references

    Guest, Oct 18, 2005, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    306
    Peter T
    Oct 19, 2005
  4. Alan

    References in VBA (Tools - References)

    Alan, Nov 28, 2005, in forum: Microsoft Excel Programming
    Replies:
    3
    Views:
    367
    Chip Pearson
    Nov 28, 2005
  5. Replies:
    1
    Views:
    782
    Peter T
    Jul 7, 2009
Loading...

Share This Page