<a href="http://www.findthepower.net/CP/CommentaryProject/PostNewABC2_PrevNext.php?BRN=ON&PrevNextNum=39762">PREVIOUS</a> <a href="http://www.findthepower.net/CP/CommentaryProject/PostNewABC2_PrevNext.php?BRN=ON&PrevNextNum=39764">NEXT</a>
In the hyperlink below, the only part of the hyperlink to change from record to record is Rev 21:6
Everything else in the following hyprlink is a constant from one record to the next.
<U><a href="http://www.findthepower.net/CP/CommentaryProject/PostNewABC2_R.php?BRN=ON&SeeAlso=Rev 21:6">Rev 21:6</a></U>
If a hyperlink does not match the above patterns, I would like the macro to insert three [[[ left brackets so I can find the improper hyperlink after the macro is run OR stop the macro at the point in the txt file where the error occurs.
Here is a Word macro that finds some errors in the url syntax but does not find all errors in the url syntax.
Sub FindBadLinks() Const Pattern1 = "<a href=""http://www.findthepower.net/CP/CommentaryProject/PostNewABC2_PrevNext.php?BRN=ON&PrevNextNum=*"">PREVIOUS</a>" Const Pattern2 = "<a href=""http://www.findthepower.net/CP/CommentaryProject/PostNewABC2_PrevNext.php?BRN=ON&PrevNextNum=*"">NEXT</a>" Const Pattern3 = "<U><a href=""http://www.findthepower.net/CP/CommentaryProject/PostNewABC2_R.php?BRN=ON&SeeAlso=*"">*</a></U>" Dim lngStart As Long Dim lngEnd As Long Dim strText As String Dim intFlag As Integer Application.ScreenUpdating = False Selection.HomeKey Unit:=wdStory With Selection.Find .ClearFormatting .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .Forward = True .Wrap = wdFindStop Do While .Execute(FindText:="<a href=") = True lngStart = Selection.Start lngEnd = Selection.End Selection.Collapse Direction:=wdCollapseEnd If .Execute(FindText:="</a>") = False Then ' No matching end tag Activedocument.Range(Start:=lngStart, End:=lngEnd).Select Selection.TypeText Text:="[[[" Activedocument.Range(Start:=lngEnd + 3, End:=lngEnd + 3).Select Else ' Found end tag intFlag = 0 lngEnd = Selection.End strText = Activedocument.Range(Start:=lngStart, End:=lngEnd).Text If strText Like Pattern1 Then intFlag = -1 ElseIf strText Like Pattern2 Then intFlag = -1 Else ' Include Underline tags strText = Activedocument.Range(Start:=lngStart - 3, End:=lngEnd + 4).Text If strText Like Pattern3 Then intFlag = -1 Else intFlag = 3 End If End If If intFlag >= 0 Then Activedocument.Range(Start:=lngStart, End:=lngStart).Select Selection.TypeText Text:="[[[" End If Activedocument.Range(Start:=lngEnd, End:=lngEnd).Select End If Loop End With Application.ScreenUpdating = True End Sub

New Topic/Question
Reply




MultiQuote






|