Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 07-19-2016, 06:41 AM
Robert K S Robert K S is offline Detecting that previous character doesn't exist (i.e., present character is first in document) Windows 7 64bit Detecting that previous character doesn't exist (i.e., present character is first in document) Office 2007
Novice
Detecting that previous character doesn't exist (i.e., present character is first in document)
 
Join Date: Jul 2016
Location: Cleveland, Ohio
Posts: 10
Robert K S is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
It appears the OP is not a fan of Words Revision Tracking so they are doing it manually.
Yes, for certain legal document applications the revision tracking doesn't cut the mustard, and the changes have to be shown in plain old underline and strikethrough. In such a regime you generally don't want stricken-through deleted text abutting right up against underlined inserted text, thus, some whitespace has to come between, as opposed to Word's revision tracking which would not have such whitespace. To make things more complicated, certain deletions have to be denoted by double brackets, as when deleting [[-]] hyphens, dashes, etc., which wouldn't otherwise be distinguishable from deleting whitespace, or otherwise when deleting small sets of characters where strikethrough would not be noticeable (e.g., striking through a single e or 4).

I've been developing a different VBA script that converts Word's revision tracking to legal-document revision format, but it's not perfect yet. I'm particularly having trouble with the part of the script that adds and deletes spaces, as appropriate, around double brackets where they have been inserted as part of the conversion process. Here's my crummy code that doesn't work, in case anyone's really interested. I think I was trying to write this before I understood fully what could be done with wildcard search & replace and I would probably do it differently now.

Code:
    For Each strChar In Selection.Range.Characters 'Add/delete spaces around double brackets
        Set strPrevPrevChar = strChar.Previous(wdCharacter, 2) 'I don't think this works
            MsgBox "Nothing selected or no revisions in selection.", vbOKOnly
        Set strPrevChar = strChar.Previous(wdCharacter, 1)
        Set strNextChar = strChar.Next(wdCharacter, 1)
        Set strNextNextChar = strChar.Next(wdCharacter, 2) 'I don't think this works
        If strChar.Text = "[" And strNextChar.Text = "[" Then 'Opening double bracket
            If strPrevChar.Text <> Chr(32) Then 'Insert leading space before opening double bracket
                strChar.InsertBefore (" ")
            Else 'Make sure there is only one leading space before opening double bracket
                Do While strPrevChar.Text = Chr(32)
                Loop
            End If
            Do While strNextNextChar.Text = Chr(32) 'Delete leading space after opening double bracket
                
            Loop
        ElseIf strChar.Text = "]" And strNextChar.Text = "]" Then 'Closing double bracket
            If strNextNextChar.Text <> Chr(32) Then 'Insert trailing space after closing double bracket
            End If
        End If
    Next strChar
PS
Thanks everybody for your help. Really fantastic answers here.
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting that previous character doesn't exist (i.e., present character is first in document) Macro to list all character styles in a document ljd108 Word VBA 11 08-28-2024 01:20 AM
Detecting that previous character doesn't exist (i.e., present character is first in document) Replace a random character with the same character RickLegrand Word 7 07-23-2015 06:35 PM
Detecting that previous character doesn't exist (i.e., present character is first in document) How can select from a specific character to another character mohsen.amiri Word 2 02-19-2015 11:38 PM
Detecting that previous character doesn't exist (i.e., present character is first in document) Regular (roman) character style doesn't change text to roman kcbenson Word 2 10-16-2014 01:31 PM
Detecting that previous character doesn't exist (i.e., present character is first in document) Finding or searching ^ character in word document shahin3121 Word 2 03-05-2012 06:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:12 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