lestng
03-17-2006, 12:30 AM
I have the following script going through a document and collect the paragraph text and url and store them in a two dimensional array but got the following error on the last ReDim statement:
Runtime error '9'
Subscript out of range.
This is my first time dealing with 2 dimensional table would really appreciate to get some help.
Sub LoopParagraphs()
Dim HyperlinkArray()
ReDim HyperlinkArray(100, 2)
Dim oRow As Integer
Dim para As Paragraph
oRow = 0
Selection.HomeKey Unit:=wdStory
For Each para In ActiveDocument.Paragraphs
If para.Style = "item:1head" Or para.Style = "item:title" Or para.Style = "item:2head" _
Or para.Style = "item:2" Then
If para.Range.Hyperlinks.count >= 1 Then
HyperlinkArray(oRow, 1) = para.Range.Hyperlinks.item(1).Address
End If
HyperlinkArray(oRow, 0) = para.Range.Text
oRow = oRow + 1
End If
Next para
ReDim Preserve HyperlinkArray(oRow, 2)
End Sub
Runtime error '9'
Subscript out of range.
This is my first time dealing with 2 dimensional table would really appreciate to get some help.
Sub LoopParagraphs()
Dim HyperlinkArray()
ReDim HyperlinkArray(100, 2)
Dim oRow As Integer
Dim para As Paragraph
oRow = 0
Selection.HomeKey Unit:=wdStory
For Each para In ActiveDocument.Paragraphs
If para.Style = "item:1head" Or para.Style = "item:title" Or para.Style = "item:2head" _
Or para.Style = "item:2" Then
If para.Range.Hyperlinks.count >= 1 Then
HyperlinkArray(oRow, 1) = para.Range.Hyperlinks.item(1).Address
End If
HyperlinkArray(oRow, 0) = para.Range.Text
oRow = oRow + 1
End If
Next para
ReDim Preserve HyperlinkArray(oRow, 2)
End Sub