Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-01-2015, 08:00 AM
Nickster Nickster is offline Modifying RTF File in MS Word 2007 Windows 7 64bit Modifying RTF File in MS Word 2007 Office 2007
Novice
Modifying RTF File in MS Word 2007
 
Join Date: Dec 2015
Posts: 2
Nickster is on a distinguished road
Default Modifying RTF File in MS Word 2007

I'm editing several RTF ebooks. I need to reformat by executing a fixed sequence of changes to the total file. For example.

Change all "TAB" characters to null
then
Change all "-" characters to null
then


Change all "PARAGRAPH" character + one SPACE to "~"
etc.

I'm new to VBA, but experienced in Xbase programming. I've reviewed different examples but remain confused. An example for executing a set of fixed sequence changes would be most appreciated.
Reply With Quote
  #2  
Old 12-02-2015, 09:27 AM
Nickster Nickster is offline Modifying RTF File in MS Word 2007 Windows 7 64bit Modifying RTF File in MS Word 2007 Office 2007
Novice
Modifying RTF File in MS Word 2007
 
Join Date: Dec 2015
Posts: 2
Nickster is on a distinguished road
Default

Please ignore post. Figured out how to use Macro record and solved problem.
Reply With Quote
  #3  
Old 12-02-2015, 11:33 PM
macropod's Avatar
macropod macropod is offline Modifying RTF File in MS Word 2007 Windows 7 64bit Modifying RTF File in MS Word 2007 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

This can all be done via two wildcard Find/Replace executions:
1. Find = [^t\-]
Replace = nothing
2. Find = ^13^32
Replace = ~
The equivalent macro would be:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Text = "[^t\-]"
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
    .Text = "^13^32"
    .Replacement.Text = "~"
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying RTF File in MS Word 2007 Title bar in word and ecxel 2010 is not picking up greek file name of 2007 file danielle Word 4 12-03-2014 07:47 AM
Modifying RTF File in MS Word 2007 Modifying list styles in word dreamz Word 1 06-30-2014 12:03 PM
Modifying RTF File in MS Word 2007 Modifying an existing table in Word janewayb Word Tables 1 04-08-2013 06:17 PM
Modifying RTF File in MS Word 2007 modifying a PST file ctspwc Outlook 5 11-17-2010 09:29 PM
Modifying RTF File in MS Word 2007 Creating Scatter XY chart in Excel 2007, modifying the Y axsis niss3 Excel 1 10-27-2010 07:41 PM

Other Forums: Access Forums

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