UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Word Find/replace Macro, Office 2007    
 
   
KathCobb
post Oct 27 2017, 01:59 PM
Post#1



Posts: 480
Joined: 18-October 06



I have a Macro I run to remove line breaks from a PDF file that I convert to text. The way it formats, it adds a bunnch of line breaks that do not belong between first and last names. I used this code putting each last name in the "text line:

CODE
With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = "CHRISTMAS, ^p"
        .Replacement.Text = "CHRISTMAS, "
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll



When I originally did it, it worked like a charm. No problems. Now it runs, but it doesn't replace anything. I have exported the code and tried it on different computers, but still no luck. I have tired first using "select all" on the document itself, but still no luck. Sometimes when it runs, it gives the message box replaced "O" Do I want to start at the beginning? And I answer yes but still nothing gets replaced.

Does anyone know any reason why this would just stop replacing and basically running and doing nothing?

I'd really appreciate the help.

Thanks

Kathy

--------------------
I'm just a beginner...take pity on me.
Go to the top of the page
 
ngins
post Oct 28 2017, 04:06 AM
Post#2



Posts: 300
Joined: 18-August 05
From: DFW, TX, USA


Maybe your document contains line breaks instead of paragraph breaks. Try using ^l (lower case L) instead of ^p, and see if that does anything.

--------------------
Neil
Accessing since '96
Go to the top of the page
 
KathCobb
post Oct 30 2017, 07:19 PM
Post#3



Posts: 480
Joined: 18-October 06



I will give that a try tomorrow. It’s very odd because I copied the entire code from MS Word on a Windows computer to a MS Word module using Word for Mac. Worked just fine. In originally writing the code, I wrote it on the Mac and it worked once and it quit. So I did the reverse, copied the code, created a new module in Word for Windows and it worked again. Is there some reset somewhere I am missing because I do use the regular find feature frequently. I do start every section of code with Clear Formatting. I’m really stumped.

Thanks for the help 😃

--------------------
I'm just a beginner...take pity on me.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    11th December 2017 - 12:56 AM