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    
post Oct 27 2017, 01:59 PM

Posts: 492
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:

With Selection.Find
        .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.


Go to the top of the page
post Oct 28 2017, 04:06 AM

Posts: 303
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.
Go to the top of the page
post Oct 30 2017, 07:19 PM

Posts: 492
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 😃
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    18th November 2018 - 08:51 PM