Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-07-2012, 07:21 AM
delasson delasson is offline Compare content of two ranges INCLUDING FORMATTING Windows 7 32bit Compare content of two ranges INCLUDING FORMATTING Office 2010 32bit
Novice
Compare content of two ranges INCLUDING FORMATTING
 
Join Date: Dec 2012
Posts: 2
delasson is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 12-08-2012, 09:24 PM
macropod's Avatar
macropod macropod is offline Compare content of two ranges INCLUDING FORMATTING Windows 7 64bit Compare content of two ranges INCLUDING FORMATTING Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 12-10-2012, 01:48 AM
delasson delasson is offline Compare content of two ranges INCLUDING FORMATTING Windows 7 32bit Compare content of two ranges INCLUDING FORMATTING Office 2010 32bit
Novice
Compare content of two ranges INCLUDING FORMATTING
 
Join Date: Dec 2012
Posts: 2
delasson is on a distinguished road
Default

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
I changed the test to:
Range1.FormattedText.Text = Range2.FormattedText.Text
But as I see it, the FormattedText.Text property contains the exact same information as the Text property on the Range object (no formatting information).
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 ;-)
Reply With Quote
  #4  
Old 12-10-2012, 03:54 AM
macropod's Avatar
macropod macropod is offline Compare content of two ranges INCLUDING FORMATTING Windows 7 64bit Compare content of two ranges INCLUDING FORMATTING Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

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
Compare content of two ranges INCLUDING FORMATTING 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
Compare content of two ranges INCLUDING FORMATTING Using COMPARE to compare more than two variables Wyskers Word 1 12-03-2011 01:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:27 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft