PDA

View Full Version : Follow Hyperlink Macro only works in Pause/Break Mode


jdutle
Dec 18, 2015, 09:57 AM
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:


Sub HLTest()
'
' HLTest Macro
'

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