+ Reply to Thread
Results 1 to 7 of 7

VBA macro for hyperlink to active workbook in the active workbook path

  1. #1
    Registered User
    Join Date
    07-05-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    42

    VBA macro for hyperlink to active workbook in the active workbook path

    I have two workbooks


    workbook 1-master is a 20-worksheet account workbook that end users will copy into a new folder, naming the folder and workbook after account they are working.

    workbook 2 is an organizing workbook that has a row dedicated to each account for which the user has a separate workbook (a renamed copy of the workbook 1)

    I've included one worksheet in workbook 1 master with a row that needs to be copied into the organizer workbook. The row contains summary data for workbook 1 including two hyperlinks: 1 referencing the renamed workbook and the other referencing the folder in which the renamed workbook is stored. Right now the end use has to manually enter the hyperlinks into the row to be copied, because the specific address does not exist until after the workbook and folders are created. I spend way too much time helping people write their hyperlinks.

    I would like to write hyperlink macros for workbook 1-master. The hyperlinks should reference the active workbook path and active workbook file name so that the end user can push a macro button AFTER they copy the master into their newly created folder with a new workbook name. I would install the button on the worksheet containing the row which needs to be copied into the Organizer workbook.

    The hyperlink for the workbook will be in Cell H1 and the hyperlink for the folder will be in I1.

    If I can get a bit of code to get started I can adapt it as needed. Any help is greatly appreciated!

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: VBA macro for hyperlink to active workbook in the active workbook path

    Why not just get the macro you are asking to create the hyperlink directly (rather than edit / self-reference)

    e.g.

    Please Login or Register  to view this content.
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

  3. #3
    Registered User
    Join Date
    07-05-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: VBA macro for hyperlink to active workbook in the active workbook path

    The hyperlinks extend across network drives. When created directly they tend to produce a roaming error after a day or two and have to be reset.

  4. #4
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: VBA macro for hyperlink to active workbook in the active workbook path

    Yes, sorry, I could have been more instructive (I was giving you the code to start from...)
    This would still work in that situation.
    The range can only sustain one hyperlink so adding a link where one exists already will overwrite. I'm just saying you don't need clever syntax to achieve what you're asking for. activeworkbook.path and activeworkbook.fullname are all you need.

  5. #5
    Registered User
    Join Date
    07-05-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: VBA macro for hyperlink to active workbook in the active workbook path

    Thanks, Charlie. I'm such a novice at VBA that I need it spelled out for me. I've never written a hyperlink and don't quite understand the syntax. Could you write me a sample based on the discussion above?....something I could copy into a module?

    I've attached both workbooks for your convenience

    Claims Organizer-master.xlsmWorkbook-Macro-edition-blank-.xlsm

  6. #6
    Registered User
    Join Date
    07-05-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    42

    Re: VBA macro for hyperlink to active workbook in the active workbook path

    Charlie, I forgot to tell you that the worksheet in the Master workbook is the "organizer" worksheet

  7. #7
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: VBA macro for hyperlink to active workbook in the active workbook path

    Hi, put this in the 'Organizer' sheet code in the workbook which isn't the organizer (I think you haven't asked for anything for the organizer workbook so I'm not sure why you've uploaded it)
    Please Login or Register  to view this content.
    Then create a (forms) button on the sheet and select the AddLinks macro from the dialogue box.

+ 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