Stumped on 2 Macro Problems

S

Scott Geeding

I'm having trouble with two issues, one probably easy, the other possibly
not so simple.

1) I need to perform a Find for just a ^p (paragraph symbol) that is alone
on a line by itself. Simply searching for ^p will also find a paragraph
symbol at the end of an actual paragraph of text, which is not what I'm
trying to do.

2) I'm in need of a text-unwrap macro. I wrote one already, which seems to
function ok I guess, but I'd like something less sloppy and more
"guaranteed" to work correctly.
 
D

Doug Robbins

For 1), you probably need to search for ^p^p, the first ^p being the one
that terminates the preceding paragraph.

For 2), I am not sure what you mean by "text unwrap" and to know if your
code can be improved upon, it would be necessary to see it. Copy and paste
it into a message that you post back here with an explanation of "text
unwrap" and someone may then be able to help.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
S

Scott Geeding

Doug Robbins" said:
For 1), you probably need to search for ^p^p, the first ^p being the one
that terminates the preceding paragraph.

For 2), I am not sure what you mean by "text unwrap" and to know if your
code can be improved upon, it would be necessary to see it. Copy and
paste it into a message that you post back here with an explanation of
"text unwrap" and someone may then be able to help.

I had thought of doing the ^p^p thing, but couldn't figure out how to switch
to only the final ^p once I had it. What I'm trying to accomplish is finding
a lone ^p and clearing the formatting on it in case it's centered, etc.
before I do further processing on the text body.

As for text unwrap, it's just like it sounds: the reverse of text wrapping.
Some files, such as a plain text ebook from Gutenberg, for example, are
hard-wrapped, and I'm trying to unwrap it so that the only actual paragraph
marker (^p again) is actually at the end of a paragraph.

My current code does a wildcard find for "([!^0013^0034.:\?\!])^0013" and
replaces with "\1 ". So far it seems to work ok, didn't know if anyone else
had any other parameters I should include in the find string or not.
 
S

Scott Geeding

Jay Freedman" said:
I think the objective is to remove unwanted paragraph marks from text
that's been pasted in from sources such as web pages.

No, actually I want to keep the paragraph marks, just clear formatting on
them is all.
 
H

Howard Kaikow

Although slow, the most direct approach may be to write a macro that uses
the paragraphs collection to find the empty paragraphs and change the format
as desired. A skeleton would be:

Public Sub ParagraphCleanup()
Dim paraCurrent As Word.Paragraph

For Each paraCurrent In ActiveDocument.Paragraphs
With paraCurrent
If Len(.Range.Text) = 1 Then
.Alignment = wdAlignParagraphLeft
End If
End With
Next paraCurrent
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top