deleting a hyperlink from shape

Frank_Aa

New Member
Joined
Apr 11, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have a number of text boxes in a sheet that i'm assigning text and hyperlink. the code under here works except for this line: shMonth.Hyperlinks.Delete.
What am I doing wrong here?

Thanks,
Frank

VBA Code:
Sub test()
Dim wS As Worksheet
Set wS = Worksheets("January")
Dim shMonth As Shape
Dim nMonth(1 To 2, 1 To 12) As String
Dim mNuber As Integer

For i = 1 To 12
    Set shMonth = wS.Shapes("TekstM" & CStr(i))
    shMonth.Hyperlinks.Delete
    If mNumber <> i Then wS.Hyperlinks.Add anchor:=shMonth, Address:="#'" & nMonth(1, i) & "'!A1"
    With shMonth.TextFrame.Characters
        If mNumber <> i Then
            .Text = nMonth(2, i)
            .Font.Bold = True
            .Font.ColorIndex = 1
        Else
            .Text = nMonth(2, i)
            .Font.Bold = False
            .Font.ColorIndex = 15
         
        End If
    End With
 Next
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
?‍♂️, found the typo... shMonth.Hyperlink.Delete (not Hyperlinks.)
 
Upvote 0
?‍♂️, found the typo... shMonth.Hyperlink.Delete (not Hyperlinks.)

Although this worked, now I have to be sure that there is a hyperlink present on the shape to be able to delete. I buypassed this by always creating hyperlink, before deleting the one i wanted gone.
But how can check if hyperlink is present in shape?
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top