![]() |
|
#1
|
|||
|
|||
![]()
Shelley Lou, I have two ideas.
Idea 1: try replacing the appropriate part of your code with this: Code:
Dim sStr As String Select Case InStr(oRngEval, sStr) = 1 Case sStr = "-" 'highlights if cross refs seperated by a dash e.g. clause 1-2 oRng.Move wdCharacter, 1 lngOffset = 0 Case sStr = ", " 'highlights if cross refs seperated by a comma e.g. clause 1, 2 oRng.Move wdCharacter, 2 lngOffset = 0 Case sStr = " - " 'highlights if cross refs seperated by a dash and space either side e.g. clause 1 - 2 THIS CURRENTLY DOESN'T WORK oRng.Move wdCharacter, 3 lngOffset = 3 Case sStr = " or " 'highlights if cross refs seperated by the word 'or' e.g. clause 1 or 2 oRng.Move wdCharacter, 4 lngOffset = 4 Case sStr = " to " 'highlights if cross refs seperated by the word 'to' e.g. clause 1 to 2 oRng.Move wdCharacter, 4 lngOffset = 4 Case sStr = " and " 'highlights if cross refs seperated by the word 'and' e.g. clause 1 and 2 oRng.Move wdCharacter, 5 lngOffset = 5 Case sStr = " and/or " 'highlights if cross refs seperated by the word 'and/or' e.g. clause 1 and/or 2 oRng.Move wdCharacter, 8 lngOffset = 8 Case Else bCompound = False End Select To find out the dashes' codes, select them and then use AscW(selection). |
#2
|
|||
|
|||
![]()
Hi Vivka, yes you are correct, the code as written will only highlight instances of ChrW(8211) but my word documents can have both ChrW(8211) and ChrW(45) within them as they are often converted from pdf to word - maybe it would be easier to do a find ChrW(45) and replace with ChrW(8211) first before running the code maybe. Thanks for responding, much appreciated.
|
#3
|
|||
|
|||
![]()
I've tested the codes below and they seem to work correctly:
Code:
Case InStr(oRngEval, " " & ChrW(45) & " ") = 1, InStr(oRngEval, " " & ChrW(8211) & " ") = 1 Code:
Case InStr(oRngEval, " " & ChrW(45) & " ") = 1 Or InStr(oRngEval, " " & ChrW(8211) & " ") = 1 |
#4
|
|||
|
|||
![]()
Hi Vivka, fantastic, the second line of code works perfectly - thank you so much
|
#5
|
|||
|
|||
![]()
Yes, we did it! It calls for drinking
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
SamDsouza | Word VBA | 3 | 03-12-2020 04:49 AM |
![]() |
steveflooks | Word | 1 | 07-19-2018 02:52 PM |
![]() |
branko | Word VBA | 1 | 03-28-2017 11:50 PM |
Is it possible to include a newline character in the replace text | desgordon | Word | 2 | 09-14-2012 02:28 AM |
![]() |
Bobosmite | Word | 2 | 05-06-2011 04:21 AM |