+ Reply to Thread
Results 1 to 4 of 4

Excel Macro for setting Reference VBA Project

  1. #1
    Registered User
    Join Date
    07-25-2012
    Location
    Norway
    MS-Off Ver
    Excel 2003
    Posts
    41

    Excel Macro for setting Reference VBA Project

    Hi,
    At some point some vb code will work fine if related Reference VBA Project was already tick on the list.
    So far I did it manually by selecting Tools-References and Tick on which one I need (on VBA code window)

    My question is: Is there any macro which can replace my manual work for doing the same task?
    for example I want to switch on the next three Reference VBA:
    1. OLE Automation
    2. Microsoft Office 15.0 Object Library
    3. Microsoft HTML Object Library

    It is something like , go and check if the XXXXX Reference VBA is not available the make it available, if already on then perform the next task.
    just for additional info, I am using excel 2013.

    Regards,
    Benny

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,935

    Re: Excel Macro for setting Reference VBA Project

    Short answer: no, probably not.

    Use Late Binding instead of Early Binding. So, Dim your variables as Object rather than specific elements, like Outlook or Word.

    https://support.microsoft.com/en-us/...-in-automation
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-25-2012
    Location
    Norway
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Excel Macro for setting Reference VBA Project

    Hi Trevor,
    Thank you for given link.

    I try to search and found the following stuff.

    1. To get a list of all available references of a excel VBA project Regardless on whether they are selected or not.
    Reference : https://social.msdn.microsoft.com/Fo...t?forum=isvvba
    and
    https://www.experts-exchange.com/que...A-project.html

    Please Login or Register  to view this content.
    The result is as shown in the next picture
    Reference_list.JPG


    2. To get the list of all active (ticked on) reference Use the following code (Thank you for Robert, Trebor76, who sent me the code written by John Walkenbach).
    I modify a bit for print the outcome on range A1.

    Please Login or Register  to view this content.
    3. To set a reference programmatically use the following code (reference: https://social.msdn.microsoft.com/Fo...forum=exceldev)

    Please Login or Register  to view this content.
    4. As a test I did the following.
    -ticked off almost all references, just left the one in use
    Before_Running_Macro.JPG

    -running the following macro
    Please Login or Register  to view this content.
    -See the change on on the list
    After_Running_Macro.JPG


    Regards,
    Benny

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,935

    Re: Excel Macro for setting Reference VBA Project

    Thank you for the follow up. Clearly you have learnt a lot in a very short time! And I have benefited from your research.

    I think you would need to test it in different environments. Given that you may develop an application in, say, Excel 2007, and then want to run it in Excel 2010 and/or Excel 2013, you may want/need to remove redundant references and add the relevant ones.

    I still suspect that it would be simpler to use Late Binding

    Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel Macro to get Reference VBA Project from an Excel file
    By bennyys in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-16-2017, 02:51 AM
  2. Windows 8, Excel 2013 and Project 2010 - Reference Error in Macro
    By microsoftexcel007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2013, 06:23 PM
  3. Setting up a project
    By bighop in forum Excel General
    Replies: 26
    Last Post: 10-05-2011, 06:24 AM
  4. Setting class to Nothing re-setting project
    By Kyle123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2011, 11:38 AM
  5. Setting Reference Library within Macro
    By treehugger87 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-14-2010, 01:07 PM
  6. reference vsto Excel ListObject in Vb.Net 2005 project/app
    By softengine in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-27-2005, 04:05 PM
  7. Help Setting Up Basic Excel Project...
    By woodman650 in forum Excel General
    Replies: 3
    Last Post: 08-12-2005, 01:05 PM

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