#1
|
|||
|
|||
Compare content of two ranges INCLUDING FORMATTING
I'm comparing the content of two ranges in Word like this:
If range1.Text = range2.Text Then ... EndIf This works fine for actual content, but I would like to include text formatting into the comparrison as well. So if I have two ranges with the same text, BUT the text in range1 is bold, I would like the comparrison to return false. Any ideas? Thanks |
#2
|
||||
|
||||
If you can rely on the correct use of Styles for the formatting, it simply becomes a matter of checking whether the same style names are used for the same ranges.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Hi Paul
Thank you for your reply. I’m sorry I wasn’t very specific in my question. I would love to have an easy way to test for formatting changes without doing a specific test for every possible formatting element (font changes, highlighting, text effects, styles, …) What I am looking for is a property (on the Range object) like the Text-property BUT it should also include formatting information. I was happy when I found out that the Range object actually has a property called FormattedText. When I read about it in the documentation, it sounds to me that this was what I was looking for, so instead of doing the test: Rang1.Text = Range2.Text Range1.FormattedText.Text = Range2.FormattedText.Text Can you – or someone else – explain me what I am able to do with the FormattedText-property on the Range object? Or are you aware of some other functionality that can help me? Thanks ;-) |
#4
|
||||
|
||||
Unless you can rely on Style-based comparisons (ie whatever formatting is used in the document relies entirely on the use of Styles), you will have to test every attribute individually. If you can rely on the use of Styles, it then becomes a matter of testing which Styles have been used, and where.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
compare, formatting, range |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WDFormatOriginalFormatting does not retain formatting when content pasted from RTF | ramsgarla | Word Tables | 1 | 10-05-2012 02:35 AM |
Send Email with VBA while also including formatting | tylerg11 | Outlook | 0 | 07-27-2012 10:49 AM |
Rich Text Content Control - Allow User Formatting | keithacochrane | Word | 1 | 05-28-2012 05:06 PM |
How to use named ranges in excel vba? | bosve73 | Excel Programming | 4 | 01-25-2012 09:26 AM |
Using COMPARE to compare more than two variables | Wyskers | Word | 1 | 12-03-2011 01:37 AM |