Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2014, 05:40 PM
TimFromPhx TimFromPhx is offline Macro to find text only footnote numbers Windows 7 32bit Macro to find text only footnote numbers Office 2007
Novice
Macro to find text only footnote numbers
 
Join Date: Apr 2014
Posts: 4
TimFromPhx is on a distinguished road
Default Is there a quicker way to search?

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
My code does one of the following functions: Find a match, Delete selection and find next match, Increment the counter.

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to find text only footnote numbers Macro to find text and replace with form field containing that text 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
Macro to find text only footnote numbers VBA code for Microsoft Word macro — select text and insert footnote ndnd Word VBA 10 01-06-2015 01:47 PM
Macro to find text only footnote numbers Need help on Macro 03- Find text - if text is blank then remove line 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:35 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft