Bullracer2
03-02-2014, 05:39 PM
Hi,
I have a number of word documents which reside in a folder which i want to search through and extract all the hyperlinks into either word or excel (not fussed which) I previously posted a similar query a few months ago trying to get the info into excel without luck and my latest effort involves an output to word, but I'm missing some logic in here as well
Sub ExtHyper()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document 'active document
Dim wdDocHp As Document
Dim Hyper As Hyperlink
Dim rngstory As StoryRanges
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
Set wdDoc = ActiveDocument
Set wdDocHp = Documents.Add
For Each Hyper In wdDoc.Hyperlinks
Hyper.Range.Copy
wdDocHp.Activate
Selection.Paste
Selection.TypeParagraph
Next
Wend
wdDoc.SaveAs "C:\hyperlinks.docx"
Set wdDoc = Nothing
Set wdDocHp = Nothing
Application.ScreenUpdating = True
End Sub
Any help would be appreciated.
Thanks,
I have a number of word documents which reside in a folder which i want to search through and extract all the hyperlinks into either word or excel (not fussed which) I previously posted a similar query a few months ago trying to get the info into excel without luck and my latest effort involves an output to word, but I'm missing some logic in here as well
Sub ExtHyper()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document 'active document
Dim wdDocHp As Document
Dim Hyper As Hyperlink
Dim rngstory As StoryRanges
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
Set wdDoc = ActiveDocument
Set wdDocHp = Documents.Add
For Each Hyper In wdDoc.Hyperlinks
Hyper.Range.Copy
wdDocHp.Activate
Selection.Paste
Selection.TypeParagraph
Next
Wend
wdDoc.SaveAs "C:\hyperlinks.docx"
Set wdDoc = Nothing
Set wdDocHp = Nothing
Application.ScreenUpdating = True
End Sub
Any help would be appreciated.
Thanks,