modify text but preserve formatting

M

Michael Goerz

Hi,

is there a way to modify the text in a range but to keep the formatting?

Specifically, I want to write a macro to trim footnotes, i.e. to remove
leading and trailing whitespace. If I do Footnote.Range.Text =
Trim(Footnote.Range.Text), I get what I want, but I lose all formatting
(e.g. italics). Unfortunately, Trim doesn't work with the FormattedText
property. I don't seem to be able to find a way to trim the footnote and
keep italics or other formatting in place.

Any ideas?

Thanks,
Michael
 
H

Helmut Weber

Hi Michael,

you might find something like that helpful,
pseudocode, untested:

with range.characters
while .last = " " or ...
.last = ""
wend

while .first = " " or ...
.first = ""
wend

A select case statement for a list of characters to be trimmed
might come in handy as well.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
M

Michael Goerz

Helmut said:
Hi Michael,

you might find something like that helpful,
pseudocode, untested:

with range.characters
while .last = " " or ...
.last = ""
wend

while .first = " " or ...
.first = ""
wend

A select case statement for a list of characters to be trimmed
might come in handy as well.
Works like a charm.

Danke
 

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