Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Spreadsheets (https://www.askmehelpdesk.com/forumdisplay.php?f=395)
-   -   Follow Hyperlink Macro only works in Pause/Break Mode (https://www.askmehelpdesk.com/showthread.php?t=819560)

  • Dec 18, 2015, 09:57 AM
    jdutle
    Follow Hyperlink Macro only works in Pause/Break Mode
    Hello.
    As part of a macro I am working on, I would like Excel to follow/open a hyperlink to another Excel workbook.

    When I CLICK ON THE HYPERLINK in the workbook, I get the warning about making sure the file is from a trustworthy source, I hit OK, and the workbook file opens just fine.

    But when I RUN THE MACRO, I get the warning about making sure the file is from a trustworthy source, I hit OK, but then the hourglass comes up, Excel pauses for a moment and then nothing happens.

    If I change the hyperlink to be a Word Doc, then when I RUN THE MACRO it opens just fine. Word starts and the document opens.

    I did find a clue I think. I accidentally hit the pause/break button when testing the macro. I then hit resume and ran the macro again and it worked as it should?! But it only works in the VB window. I tried mapping the macro to a button in the workbook after things were working, but when I clicked it to run the macro things behaved as before. The file wouldn’t open.

    Why does it work after the pause/break button has been pressed, and only in the VB window?
    Is there a way I can recreate that effect of pause/break in the macro as it runs so that it always works as it should. Thanks for any and all help!

    The code I am using to follow the hyperlink is below:

    Code:

    Sub HLTest()
    '
    ' HLTest Macro
    '
     
    '
        Range("B4").Select
        Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
      End Sub


  • All times are GMT -7. The time now is 06:36 PM.