Hello dear VBA gurus, coding geniuses, and dumb newbies (like myself).
The question I am about to ask is asked many, many times. But I could not found an elegant and good-working solution. The problem is this:
When you import or simply copy/paste from Adobe PDF (or some other clumsy format) file into MS Word 2007, often the paragraphs are truncated. (Every single line becomes new paragraph.)
Of course, even a dumb newbie (like myself) can record a macro to replace the Paragraph mark (^p) with <Space>, but this macro is very annoyingly interrupted by the Word_2007 question:
Word has finished searching the selection. X replacements were made.And before you suggest the following solution:
Do you want to search the reminder of the document?
Yes | No
Application.DisplayAlerts = False
I will tell you - this is not working, because Application.DisplayAlerts = False suppress the dialog box but with the DEFAULT answer (Yes)! And the result is catastrophic replacement in the whole document.
Here is the code of the first macro I use:
' Para_Join Macro
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
'HERE WORD ASKS THE ANNOYING QUESTION Yes/No
Selection.MoveDown Unit:=wdLine, Count:=1
End Sub[/VBA]Please, please tell me how to bypass the Yes|No dialog box with answer No, in the above macro. (I have to edit ~400 pages truncated paragraphs.)
The other macro for replacing <paragraph> with <space> is killing the formatting (bold, italic, etc.):
' Macro to replace <Paragraph character> with <Space>
' START FROM THE END OF THE DOCUMENT (Upwards)!
' And Turn OFF "Use Smart Paragraph Select"!
Dim sText As Range
Set sText = Selection.Range
If Len(sText) = 0 Then
MsgBox "Hey stupid, you have no text selected!", vbCritical
sText = Replace(sText, Chr(13), Chr(32))
Selection.MoveUp Unit:=wdLine, Count:=1
End Sub[/VBA]If you know how to preserve font formatting in the above macro, please tell me.
Thank you very much for your time, knowledge and patience.
By the way, the AutoFormat feature of Word 2007 also is not a solution. It works sometimes, but with very crazy PDFs the result of AutoFormat is also crazy.