bstephens
08-24-2010, 11:36 PM
OK, here is the scenario. I typically get documents from outside sources that have what I call "hard numbering", meaning that "legal style numbering" is manually typed in, and tab characters (or space characters) are used to manually space the "hard numbered" document. (the numbering usually takes the following format 1.1, 1.1, 1.1.1, etc., with spaces and tabs all over the place)
I would like to be able remove the hard numbering at the beginning of each paragraph without removing any numbering which is cross-referenced in the document, so that I can apply auto numbering contained in my style set.
So for example, if an excerpt of the document looks like this:
1.11 Permitted Exceptions. Except as disclosed at 4.1, the permitted exceptions are as follows:
In the above example, I would like the macro to remove "1.11" (because it is at the beginning of the paragraph, but not "4.1" because it lies in the body of the paragraph. (I am not concerned with this macro removing tab characters or space characters, I already have separate macros to handle that, I would like this macro to only focus on removing hard numbering at the beginning of a paragraph. I'm also OK with the macro only handling "legal style" numbering)
I have the following code as a start:
Sub RemoveHardNumberingAll()
Call RemoveHardNumberingLevel3
Call RemoveHardNumberingLevel2
Call RemoveHardNumberingLevel1
End Sub
Sub RemoveHardNumberingLevel3()
Call MasterCleaner("^#^#.^#^#.^#^#", "") '11.11.11
Call MasterCleaner("^#^#.^#^#.^#", "") '11.11.1
Call MasterCleaner("^#^#.^#.^#^#", "") '11.1.11
Call MasterCleaner("^#^#.^#.^#", "") '11.1.1
Call MasterCleaner("^#.^#^#.^#^#", "") '1.11.11
Call MasterCleaner("^#.^#^#.^#", "") '1.11.1
Call MasterCleaner("^#.^#.^#^#", "") '1.1.11
Call MasterCleaner("^#.^#.^#", "") '1.1.1
Sub RemoveHardNumberingLevel2()
Call MasterCleaner("^#^#.^#^#", "") '11.11
Call MasterCleaner("^#^#.^#", "") '11.1
Call MasterCleaner("^#.^#^#", "") '1.11
Call MasterCleaner("^#.^#", "") '1.1
End Sub
Sub RemoveHardNumberingLevel1()
Call MasterCleaner("^#^#.", "") '11.
Call MasterCleaner("^#.", "") '1.
End Sub
Sub MasterCleaner(vFindText As String, vReplText As String)
If Documents.Count = 0 Then Exit Sub
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = vFindText
.Replacement.Text = vReplText
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Does anyone know how to modify so that the function "RemoveHardNumberingAll" only gets rid of numbers at the beginning of a paragraph? Would also appreciate any input on modifications that could make this code more faster, shorter, and more efficient.
Appreciate any input on this.
Best,
Brian
I would like to be able remove the hard numbering at the beginning of each paragraph without removing any numbering which is cross-referenced in the document, so that I can apply auto numbering contained in my style set.
So for example, if an excerpt of the document looks like this:
1.11 Permitted Exceptions. Except as disclosed at 4.1, the permitted exceptions are as follows:
In the above example, I would like the macro to remove "1.11" (because it is at the beginning of the paragraph, but not "4.1" because it lies in the body of the paragraph. (I am not concerned with this macro removing tab characters or space characters, I already have separate macros to handle that, I would like this macro to only focus on removing hard numbering at the beginning of a paragraph. I'm also OK with the macro only handling "legal style" numbering)
I have the following code as a start:
Sub RemoveHardNumberingAll()
Call RemoveHardNumberingLevel3
Call RemoveHardNumberingLevel2
Call RemoveHardNumberingLevel1
End Sub
Sub RemoveHardNumberingLevel3()
Call MasterCleaner("^#^#.^#^#.^#^#", "") '11.11.11
Call MasterCleaner("^#^#.^#^#.^#", "") '11.11.1
Call MasterCleaner("^#^#.^#.^#^#", "") '11.1.11
Call MasterCleaner("^#^#.^#.^#", "") '11.1.1
Call MasterCleaner("^#.^#^#.^#^#", "") '1.11.11
Call MasterCleaner("^#.^#^#.^#", "") '1.11.1
Call MasterCleaner("^#.^#.^#^#", "") '1.1.11
Call MasterCleaner("^#.^#.^#", "") '1.1.1
Sub RemoveHardNumberingLevel2()
Call MasterCleaner("^#^#.^#^#", "") '11.11
Call MasterCleaner("^#^#.^#", "") '11.1
Call MasterCleaner("^#.^#^#", "") '1.11
Call MasterCleaner("^#.^#", "") '1.1
End Sub
Sub RemoveHardNumberingLevel1()
Call MasterCleaner("^#^#.", "") '11.
Call MasterCleaner("^#.", "") '1.
End Sub
Sub MasterCleaner(vFindText As String, vReplText As String)
If Documents.Count = 0 Then Exit Sub
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = vFindText
.Replacement.Text = vReplText
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Does anyone know how to modify so that the function "RemoveHardNumberingAll" only gets rid of numbers at the beginning of a paragraph? Would also appreciate any input on modifications that could make this code more faster, shorter, and more efficient.
Appreciate any input on this.
Best,
Brian