Share via

hyperlink dialog vba

Anonymous
2012-03-20T06:58:22+00:00

Can I invoke the Hyperlink Dialog from Excel VBA ?

I'd like to use it in much the same way as GetSaveFilename.

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

HansV 462.6K Reputation points
2012-03-20T07:55:24+00:00

GetSaveAsFileName returns the filename specified by the user but it doesn't actually save - you as programmer have to do that.

You can use

Application.Dialogs(xlDialogInsertHyperlink).Show

to display the Insert Hyperlink dialog, but when the user clicks OK, the hyperlink is created.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

4 additional answers

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2012-03-20T14:52:38+00:00

    Use code like this to add a hyperlink to a shape:

        Worksheets(cSheet).Hyperlinks.Add Anchor:=shp, Address:="", SubAddress:=cLink

    Was this answer helpful?

    0 comments No comments
  2. HansV 462.6K Reputation points
    2012-03-20T14:46:38+00:00

    There is no built-in dialog constant for displaying the Macros dialog (it makes little sense to display this dialog while a macro is running), but you could try

    CommandBars.FindControl(ID:=186).Execute

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2012-03-20T11:11:00+00:00

    Hans

    Works very well, thanks.

    Next question - when updating a hyperlink programmatically, the link refuses to give me the correct answer when trying to link to a cell in the same file, even when I take the property from a working link and simply place it back into the same link.

    ' cLink is taken from the address property of the original shape

    ' cSheet is the activesheet (but in my case won't always be)

    'cObject is the name of the object against which the link is being updated

    Set shp = Sheets(cSheet).Shapes(cObject)

    With shp

           .Hyperlinks.Item(1).Name = cLink

           .Hyperlinks.Item(1).Address = cLink

    End With

    What I get is a link based on an 'Existing File or Web Page'

    What I want is a link to a 'Place in This Document'

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-03-20T09:09:07+00:00

    Is there a way to get the link returned ?

    Also, is there a similar dialog option for selecting a macro ?

    Was this answer helpful?

    0 comments No comments