![]() |
#24
|
|||
|
|||
![]()
Hi Greg, yes that has definitely worked, thank you so much. Thank you for suggesting I split the previous code into a few sections so I can identify any errors easily. I've run each section individually to see how they perform before updating the MainProcedure code with the various Calls and for some reason, the CompoundCRs code is changing spaces after periods at the end of sentences from two spaces to one space (our housestyle is two spaces). I can't see why this is happening though.
I've been trying to update the CompoundCRs code to include if there is a space or non-breaking space present but nothing has worked yet so I remembered what you said in an earlier post that sometimes its best to remove something and put it back in at the end, so I've added a find and replace in the CompoundCRs Code to remove any non-breaking spaces associated with the cross references and created a new Call to reinstate the non-breaking spaces at the end of the process. I can't thank you enough for your help on this, it will really help me a lot when housestyling documents going forward. Code:
Sub DPU_ReinstateNonBreakingSpaces_CRs() Dim oRng As Range, fld As Field, sFind1 As String, arr() As String, i As Long sFind1 = "[Aa]rticle [Aa]rticles [Aa]ppendix [Aa]ppendices [Cc]lause [Cc]lauses [Pp]aragraph [Pp]aragraphs [Pp]art [Pp]arts [Ss]chedule [Ss]chedules [Ss]ection [Ss]ections Act [Rr]egulation [Rr]egulations [Oo]rder [Rr]ule [Rr]rules" Set oRng = ActiveDocument.Range With oRng.Find .ClearFormatting .Replacement.ClearFormatting .Format = False .Forward = True .Wrap = wdFindContinue .MatchWildcards = True arr = Split(sFind1, " ") For i = 0 To UBound(arr) .text = "(" & arr(i) & ") ([0-9.]{1,})" 'NBS for clause etc. references in the array .Replacement.text = "\1^s\2" .Execute Replace:=wdReplaceAll Next For Each fld In oRng.Fields 'Spaces before auto cross-refs are NBS If fld.Type = wdFieldRef Then If Not fld.Result.Previous Is Nothing Then Set oRng = fld.Result.Previous.Characters(1) If oRng.text = Chr(32) Then oRng.text = Chr(160) End If End If Next End With End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
teza2k06 | Excel | 8 | 02-11-2022 08:41 AM |
Converting a Select statement in Excel to an update statement | shabbaranks | Excel Programming | 5 | 10-31-2018 11:47 PM |
![]() |
cangelis | Excel | 2 | 04-08-2015 05:55 PM |
![]() |
Tony Singh | Excel | 6 | 03-04-2015 12:52 PM |
![]() |
cangelis | Excel | 4 | 01-03-2014 09:10 AM |