Track change function

M

M K

Word VBA function to output change indications?

I'm dumping text from a DOORS DXL script to a Word template and I want to show changes. Is there a Word VBA function that takes two input strings and outputs a string formatted as if track changes was turned on.

Example

Input 1: The man enjoys ice cream.
Input 2: The man enjoys cake.
Output: The man enjoys <strikeout>ice cream</strikeout><u>cake</u>.

Thanks.


Submitted via EggHeadCafe - Software Developer Portal of Choice
..NET ListView Control Export To CSV File
http://www.eggheadcafe.com/tutorial...60-73af32d0de43/net-listview-control-exp.aspx
 
D

Doug Robbins - Word MVP

You could use the Document.Compare method to produce a document that had all
of the changes marked in it and then run some code to go through document
inserting the appropriate tags before and after each change and accepting
the changes.

Or, you could drive yourself crazy trying to further develop the following
so that it could handle all of the possible cases:

Dim Input1 As Variant, Input2 As Variant, Output As String
Dim i As Long, j As Long

Input1 = Split("The man enjoys ice cream.", " ")
Input2 = Split("The man enjoys cake.", " ")
Output = ""
If UBound(Input1) <= UBound(Input2) Then
j = UBound(Input1)
Else
j = UBound(Input2)
End If
For i = 0 To j
If Input2(i) = Input1(i) Then
Output = Output & Input1(i) & " "
Else
Output = Output & "<strikeout>" & Input1(i) & "</strikeout>" & "<u>"
& Input2(i) & "</u>"
End If
Next i
MsgBox Output

That returns

The man enjoys <strikeout>ice</strikeout><u>cake</u>

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

in message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top