I have a template that copies data from a local HTML file into a new file, creates headings and then creates a table at the top of the new document with hyperlinks to the various Headings within the document.
The code I am using, at the bottom of the post, works perfectly using W2K, but when run in W2K2 it will fill the first column just fine, but as soon as it starts to fill the second column with the hyperlinks Word Freezes and then eventually crashes.
I have spent all day searching the MSKB, Google and the Usenet for anything that even remotely similar. Does anyone have any idea of this is a bug in W2K2? Or is my code wrong?
Thanks for any insight.
' Get Rows and Columns for Link table at the top intCount = docMe.Bookmarks.Count intMaxCol = 4 ' Figure out the number of rows needed If intCount Mod intMaxCol = 0 Then intMaxRow = intCount / intMaxCol Else intMaxRow = Int(intCount / intMaxCol) + 1 End If ' Create Table Set rng = docMe.Range(docMe.Content.Start, docMe.Content.Start) Set tbl = docMe.Tables.Add(rng, intMaxRow, intMaxCol, , wdAutoFitContent) ' Remove Table Borders tbl.Borders.InsideLineStyle = wdLineStyleNone tbl.Borders.OutsideLineStyle = wdLineStyleNone ' Set starting values of Row and Column intRow = 1 intColumn = 1 For Each par In docMe.Paragraphs ' Is the paragraph an H3 If par.Style = "Heading 3" Then ' Set Name for Hyperlink strHLink = Left$(par.Range.Text, Len(par.Range.Text) - 1) ' Loop through State Names to get the right one For intLoop = 0 To UBound(aryStates()) If aryStates(intLoop, 0) = strHLink Then ' Add a Hyperlink in the table to the State Name ' docMe.Hyperlinks.Add tbl.Cell(intRow, intColumn).Range, , _ aryStates(intLoop, 1), , strHLink 'The line above was the original line that freezes Word 'I changed it to the line below and it still freezes here docMe.Hyperlinks.Add Anchor:=tbl.Cell(intRow, intColumn).Range, _ SubAddress:=aryStates(intLoop, 1), TextToDisplay:=strHLink Exit For End If Next ' Increment Rows and Columns for Down and then over If intRow = intMaxRow Then intRow = 1 intColumn = intColumn + 1 Else intRow = intRow + 1 End If End If Next
Any ideas? Any suggestions?
This is being run on WinXPP SP1
Thanks