![]() |
|
#1
|
|||
|
|||
![]()
I created a form with the following code:
It works okay, but the process is too slow because I get too many false matches. Code:
Public FootnoteCounter As Integer Private Sub CurrentFootnote_Change() FootnoteCounter = Me.CurrentFootnote.Value End Sub Public Sub FindFootnote_Click() Selection.Find.ClearFormatting With Selection.Find .Text = FootnoteCounter .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute End Sub Public Sub DeleteFootnote_Click() Selection.Delete Selection.Find.ClearFormatting With Selection.Find .Text = FootnoteCounter .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute End Sub Public Sub IncrementCounter_Click() FootnoteCounter = FootnoteCounter - 1 Me.CurrentFootnote.Value = FootnoteCounter Selection.HomeKey Unit:=wdStory End Sub I'm starting with the highest footnote number and working through backwards because it is quicker. For instance searching for "1" returns 1, 11, 141, 1990, etc. I get less errors if I search in reverse. Can you think of a way to do a search for "1" that would not find 11, 141, 1990, etc? Is there a way I could use a regular expression to do the search that would exclude numerals to the left or right of my target? Thanks for all your help Last edited by macropod; 04-10-2014 at 06:51 PM. Reason: Added code tags & formatting |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
iiiiifffff | Word VBA | 16 | 06-04-2016 01:47 AM |
Macro to find text in between two characters and then format selected text? | qcom | Word | 5 | 02-19-2015 11:23 PM |
![]() |
ndnd | Word VBA | 10 | 01-06-2015 01:47 PM |
![]() |
simpleonline1234 | Word VBA | 1 | 02-25-2011 02:28 AM |
Find and replace page numbers in body of text | tollanarama | Word | 3 | 02-13-2011 06:00 AM |