Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2020, 09:29 AM
alex100 alex100 is offline Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Windows 7 64bit Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Office 2016
Advanced Beginner
Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property

Is there a way to search and replace all the text that's flagged with the 'wdDeletedTextMarkStrikeThrough' property?

I tried the code below, but it doesn't work...

Code:
  With ActiveDocument.Content.Find


.ClearFormatting .Font.DeletedTextMark = wdDeletedTextMarkStrikeThrough With .Replacement .ClearFormatting .Font.ColorIndex = wdRed End With .Execute FindText:="", ReplaceWith:="", Format:=True, Replace:=wdReplaceAll End With
Once it has been marked in red, I'd like to reject all the document revisions, so that the text will not get deleted. The following code line seems to work fine:

Code:
     ActiveDocument.RejectAllRevisions
Thank you!

Alex
Reply With Quote
  #2  
Old 08-30-2020, 04:11 PM
Guessed's Avatar
Guessed Guessed is offline Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Windows 10 Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Is your aim to convert tracked deletions to a font format with red strikethrough? If so, wouldn't it make more sense to loop through the revisions to find all the deletions?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-30-2020, 11:40 PM
alex100 alex100 is offline Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Windows 7 64bit Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Office 2016
Advanced Beginner
Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default

Thank you for your suggestion, Andrew!

I managed to find the way to loop through the document revisions and reject them, but right now I am unable to change their font style... I would be mainly interested in changing the font color, and its shading color (Font.Shading.BackgroundPatternColor).

The code below is what I have so far, but not fully working (font colors do not get changed)...

Code:
For Each oRevision In ActiveDocument.Revisions
    If (oRevision.Type = 2) Then
        oRevision.Reject
        oRevision.Range.Font.Color = wdColorRed
        oRevision.Range.Font.Shading.BackgroundPatternColor = RGB(222, 222, 222)
    End If
Next oRevision
My aim is to reject all tracked deletions (the strike-throughs will automatically get deleted with that) and then change the font characteristics.

I am actually using this with a JavaScript that highlights keywords on the web. The problem is that when I load FireFox Reader View (F9), the JavaScript CSS highlights are no longer displayed. That's because Reader View ignores all CSS stylings, no matter what. Anyhow, after a lot of searching and digging, I managed to find an HTML tag that I can use to mark these keywords. So, using the '<del>' tag, these keywords show up with a strike-through in Reader View mode. That's ok, because I only need to copy and paste this data into MS Word documents, where later I will reverse the process and re-highlight the original keywords. Sure, it's not the most elegant solution, but I have not found any other way to copy data from Reader View into Word and preserve the keyword highlighting. I choose Reader View instead of the regular FireFox view because the content is much better formatted for reading. All I need to do is switch to Reader View, select the entire page with Ctrl + A, and copy/paste the content into MS Word (where other formatting macros are run).

Alex
Reply With Quote
  #4  
Old 08-31-2020, 01:23 AM
Guessed's Avatar
Guessed Guessed is offline Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Windows 10 Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Looping from the start can be bad if you are changing the number of revisions inside your loop. You should start from the back if that is the case. If rejecting the revision is problematic, maybe make sure you aren't revision tracking the font formatting steps.
Code:
Sub ManualRevisions()
  Dim iRev As Long
  ActiveDocument.TrackRevisions = False
  For iRev = ActiveDocument.Revisions.Count To 1 Step -1
    With ActiveDocument.Revisions(iRev)
      Select Case .Type
        Case wdRevisionDelete, wdRevisionCellDeletion    '2 & 17
          .Range.Font.ColorIndex = wdRed
          .Range.Font.Shading.BackgroundPatternColor = RGB(222, 222, 222)
          .Reject
      End Select
    End With
  Next iRev
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 08-31-2020, 06:02 AM
alex100 alex100 is offline Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Windows 7 64bit Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Office 2016
Advanced Beginner
Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default

Thank you very much, Andrew! The code works great.

Alex
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to find text, replace with multiple lines of text noslenwerd Word VBA 3 12-31-2019 11:04 AM
Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Find and replace text with wildcards arunchandar9 Word VBA 15 06-30-2019 01:06 AM
Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Macro to find text and replace with form field containing that text iiiiifffff Word VBA 16 06-04-2016 01:47 AM
Macro to find coloured text and replace with form-field/formtext containing that text tarktran Word VBA 1 11-26-2014 08:12 AM
Find and replace all the text flagged with the 'wdDeletedTextMarkStrikeThrough' property Find and replace a string of text errtu Word 1 01-31-2013 02:09 PM

Other Forums: Access Forums

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