Hi All,
I have multiple shapes & text boxes in a sheet. I want to extract the hyper links of those shapes or text boxes which have hyper links in them. But not able to get that done.
Requesting your guidance to get this solved.
Regards
Sudhir
Hi All,
I have multiple shapes & text boxes in a sheet. I want to extract the hyper links of those shapes or text boxes which have hyper links in them. But not able to get that done.
Requesting your guidance to get this solved.
Regards
Sudhir
[VBA]Sub blah()
For Each shp In ActiveSheet.Shapes
MsgBox shp.Hyperlink.Address & vbLf & shp.Hyperlink.SubAddress
Next shp
End Sub
[/VBA]
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Thanks p45cal. I will try this out & let you know.
Regards
Sudhir
Hi p45cal,
Thanks for your guidance but the below code is giving me an "Application-defined or object-defined" error. I am using below code
[VBA]Sub blah()
cnt = 2
For Each shp In sheets("sheet1").Shapes
sheets("sheet2").Range("B" & cnt).valuE = shp.Name
sheets("sheet2").Range("B" & cnt).value = shp.Hyperlink.Address & vbLf & shp.Hyperlink.SubAddress
cnt = cnt+1
Next shp
End Sub [/VBA]
I am getting error in line
[VBA]sheets("sheet2").Range("B" & cnt).value = shp.Hyperlink.Address & vbLf & shp.Hyperlink.SubAddress [/VBA]
Is this error because that particular shape do not have a hyperlink ..?? If so, then can we check if that shape has a hyperlink then extract the same.
Appreciating your guidance.
Regards
Sudhir
Hi p45cal,
Yep, this error is due to non-availability of hyperlink in that shape. Is it possible to check if a shape has hyperlink, if yes then extract the link ...??
Regards
Sudhir
maybe
[vba]
Sub blah()[/vba]
cnt = 2
For Each shp In Sheets("sheet1").Shapes
If shp.Hyperlinks.Count > 0 Then
Sheets("sheet2").Range("B" & cnt).Value = shp.Name
Sheets("sheet2").Range("B" & cnt).Value = shp.Hyperlink.Address & vbLf & shp.Hyperlink.SubAddress
cnt = cnt + 1
End If
Next shp
End Sub
PLS DO NOT PM; OPEN A THREAD INSTEAD!!!
1) Posting Code
[CODE]PasteYourCodeHere[/CODE]
(or paste your code, select it, click # button)
2) Uploading File(s)
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.
3) Testing the Codes
always back up your files before testing the codes.
4) Marking the Thread as Solved
from Thread Tools (on the top right corner, above the first message)
Hi Mancubus,
Thanks for the guidance.
This is not working as I am getting an error "Object doesn't support this property or method" in line
[VBA] If shp.Hyperlinks.Count > 0 Then [/VBA]
Regards
Sudhir
try:[VBA]Sub blah()
Dim cc As Hyperlink
cnt = 2
For Each shp In Sheets("sheet1").Shapes
Set cc = Nothing
On Error Resume Next
Set cc = shp.Hyperlink
On Error GoTo 0
If Not cc Is Nothing Then
Sheets("sheet2").Range("B" & cnt).Value = shp.Name
Sheets("sheet2").Range("B" & cnt).Value = cc.Address & vbLf & cc.SubAddress
cnt = cnt + 1
End If
Next shp
End Sub
[/VBA]
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Thanks p45cal. It works perfectly.
Just a small query.. if i want to extract the innertext of the shape how to get that done ..??
Appreciating your time & efforts for the guidance.
Thanks a lot ..!!!
Regards
Sudhir
Try also:
Edit: See if the bold line works for you to extract text on the shape.
[vba]Public Sub ExtractHyperlinks()
Dim hlnk As Hyperlink
Dim cnt As Long
cnt = 2
For Each hlnk In ActiveSheet.Hyperlinks
' hlnk.type = 0 if it is in cell
' hlnk.type = 1 if it is on shape
If hlnk.Type = 1 Then
Sheets("Sheet2").Range("B" & cnt).Value = hlnk.Shape.Name
Sheets("Sheet2").Range("C" & cnt).Value = hlnk.Address & vbLf & hlnk.SubAddress
Sheets("Sheet2").Range("D" & cnt).Value = hlnk.Shape.TextFrame.Characters.Caption
cnt = cnt + 1
End If
Next hlnk
End Sub[/vba]
Last edited by shrivallabha; 12-15-2012 at 07:13 AM.
Regards,
--------------------------------------------------------------------------------------------------------
Shrivallabha
--------------------------------------------------------------------------------------------------------
Using Excel 2016 in Home / 2010 in Office
--------------------------------------------------------------------------------------------------------
Thanks shrivallabha, it works. I am using the below code
[VBA] Sheets("Sheet2").Range("D" & cnt).Value = shp.TextFrame.Characters.Caption[/VBA]
My issue is completely solved. I thanks p45cal, shrivallabha & mancubus for their guidance.
Thanks a lot ...!!!
Regards
Sudhir