tiovandercruz
New member
- Joined
- Jul 29, 2010
- Messages
- 1
- Programming Experience
- Beginner
I have a program which exports all hyperlink text and address to an excel file.
I want to add a if clause that checks if there are no hyperlinks in the document and if there are 0 hyperlinks display a message that there are no hyperlinks in this document.
The problem is that word is divided in stories, so the body of the document is a separate story from the footnotes story of the same document.
So when I attempt to check for hyperlinks the if statement only checks the body and if there are no hyperlinks in the body exits the program even though there may be hyperlinks in the footnotes story.
I use the code below to do the check:
The following code works for deleting all hyperlinks in both stories, but the problem is that
does not seem to work.
Does anybody know how to get around this problem?
I want to add a if clause that checks if there are no hyperlinks in the document and if there are 0 hyperlinks display a message that there are no hyperlinks in this document.
The problem is that word is divided in stories, so the body of the document is a separate story from the footnotes story of the same document.
So when I attempt to check for hyperlinks the if statement only checks the body and if there are no hyperlinks in the body exits the program even though there may be hyperlinks in the footnotes story.
I use the code below to do the check:
VB.NET:
Sub ListHyperlinks()
Dim oDoc As Document
Dim oStory As Range
Dim oHlink As Hyperlink
Dim srcDoc As Document, destDoc As Document
Dim HL As Hyperlink
Dim hlk As Range
For Each oStory In ActiveDocument.StoryRanges
If ActiveDocument.Hyperlinks.Count = 0 Then
MsgBox "There are no hyperlinks in this document.", _
vbExclamation, "Exit"
Exit Sub
Else
On Error Resume Next
' code that does the hyperlink exporting
End If
Next
End Sub
The following code works for deleting all hyperlinks in both stories, but the problem is that
VB.NET:
if count.oHlink.Range = 0 then
VB.NET:
Sub RemoveAllHyperlinks()
Dim oDoc As Document
Dim oStory As Range
Dim oHlink As Hyperlink
For Each oStory In ActiveDocument.StoryRanges
For Each oHlink In oStory.Hyperlinks
oHlink.Range.Delete
Next
Next
End Sub
Does anybody know how to get around this problem?