Share via

Using Workbook.FollowHyperlink Method's ExtraInfo and Method parameters

Anonymous
2015-09-28T01:29:22+00:00

When I execute the following line of code:

    Activesheet.Range("A1").Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

a dialog box appears with the following message:

"Some files can contain viruses or otherwise be harmful to your computer.

It is importnt to be certain that this file is from a trustworthy source.

Would you like to open this file?"

At the bottom of the dialog box are two buttons: OK and Cancel.  Cancel is the default button.

I would like to utilize the Workbook.FollowHyperlink Method's ExtraInfo and Method parameters to automatically "click" the OK button.

I've tried the following line of code, but with no success:

     Activesheet.Range("A1").Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True, _

          ExtraInfo:=Chr(9) + Chr(13), Method:=msoMethodPost

Can someone from this forum kindly tell me how to modify the previous line of code to have the Workbook.FollowHyperlink Method automatically "click" the OK button in the dialog box?

Thanks in advance for any assistance.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

OssieMac 48,001 Reputation points Volunteer Moderator
2015-09-28T06:34:37+00:00

it ended up inserting a tab and a new line in the VBE window.  I then tried executing the SendKeys line after the FollowHyperlink line, but it did not "execute" within the dialog box I mentioned in my original post.

Running from the VBA editor does that. Try running from a command button on the worksheet.

The line cannot be after the Hyperlink code because the hyperlink line does not finish processing until after the selection is made on the popup.

Was this answer helpful?

0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-09-28T06:04:44+00:00

    Thanks for your solution.  Unfortunately, when the SendKeys line executed, it ended up inserting a tab and a new line in the VBE window.  I then tried executing the SendKeys line after the FollowHyperlink line, but it did not "execute" within the dialog box I mentioned in my original post.

    Thanks again for your help.

    Regards,

    Bob

    Was this answer helpful?

    0 comments No comments
  2. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2015-09-28T04:51:20+00:00

    "Some files can contain viruses or otherwise be harmful to your computer.

    It is importnt to be certain that this file is from a trustworthy source.

    Would you like to open this file?"

    Have also a look here:

    https://support.microsoft.com/en-us/kb/925757

    Andreas.

    Was this answer helpful?

    0 comments No comments
  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. OssieMac 48,001 Reputation points Volunteer Moderator
    2015-09-28T03:16:14+00:00

    Application.SendKeys ("{TAB}~")

    ActiveSheet.Range("A1").Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

    Explanation of SendKeys command:  {TAB} changes the button and ~ is the Enter key.

    After thought: SendKeys is not overly reliable so you will need to test to ensure they do as required.

    Was this answer helpful?

    0 comments No comments