Fixing breaks in formatting (ie. italicized sentence, but spces are not italics)


C

CompleteNewb

I'm just curious here, and thought I'd ask.

I've discovered that a lot of the italicized phrases in my VERY long Word
document have the WORDS in italics, but for some reason the spaces between
the words are NOT. So, when I run my macro to place all italicized phrases
inside html tags, I get every word enclosed in the tags instead of the
entire sentence/phrase.

Is there any way to:

1) Fix the non-formatted SPACES between words that are italicized in Word
before running the macro OR
2) Fixing it within the code of the macro.

Here's what I have for the bracket thing:

Set MyRange = ActiveDocument.Content
With MyRange.Find
.ClearFormatting
.Font.Italic = True
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = "<em>^&</em>]"
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
End With

Thanks for any ideas or comments on this, and for taking the time
 
Ad

Advertisements

G

grammatim

I'm just curious here, and thought I'd ask.

I've discovered that a lot of the italicized phrases in my VERY long Word
document have the WORDS in italics, but for some reason the spaces between
the words are NOT. So, when I run my macro to place all italicized phrases
inside html tags, I get every word enclosed in the tags instead of the
entire sentence/phrase.

Is there any way to:

1) Fix the non-formatted SPACES between words that are italicized in Word
before running the macro OR
2) Fixing it within the code of the macro.

Here's what I have for the bracket thing:

Set MyRange = ActiveDocument.Content
With MyRange.Find
.ClearFormatting
.Font.Italic = True
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = "<em>^&</em>]"
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
End With

Thanks for any ideas or comments on this, and for taking the time

I'm no professional, just stopped in to see if my question has been
addressed yet, so maybe I'm missing something -- but this sounds like
a simple Find - Replace operation. If for some reason you don't want
to simply Select All and click Italic, you can open the Replace panel
(Ctrl-H, though it's not impossible that they've changed it in 2007),
type a space in the upper box; place the cursor in the lower box, type
a space, click More, click Format, choose Font, select Italic, then
either go ahead and click Replace All, or test it on one example with
Find Next and Replace.
 
C

CompleteNewb

Thanks for your response, but the entire document is not in italics, just
some phrases and sentences, as in a typical publication (italicized book
titles, quotes, etc.), with the rest normal non-italicized. I don't want to
turn the whole document into italics, I just want to get the italicized
phrases and sentences to be italicized in their entirety, instead of
italicized words broken up with NONitalicized spaces.

Example:

The favorite book among young readers is <italics start>Jack<italics stop>
<italics start>and<italics stop> <italics start>the<italics stop> <itsalics
start>Beanstalk<italics stop>

I'm using the <italics start> and <italics stop> becuase I'm posting in
plain text. But you can see that the problem, as specified in my first
post, is that within the italicized phrase, which looks fine when printed,
there are nonitalicized spaces (I don't know how that happened, but it did).


grammatim said:
I'm just curious here, and thought I'd ask.

I've discovered that a lot of the italicized phrases in my VERY long Word
document have the WORDS in italics, but for some reason the spaces
between
the words are NOT. So, when I run my macro to place all italicized
phrases
inside html tags, I get every word enclosed in the tags instead of the
entire sentence/phrase.

Is there any way to:

1) Fix the non-formatted SPACES between words that are italicized in
Word
before running the macro OR
2) Fixing it within the code of the macro.

Here's what I have for the bracket thing:

Set MyRange = ActiveDocument.Content
With MyRange.Find
.ClearFormatting
.Font.Italic = True
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = "<em>^&</em>]"
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
End With

Thanks for any ideas or comments on this, and for taking the time

I'm no professional, just stopped in to see if my question has been
addressed yet, so maybe I'm missing something -- but this sounds like
a simple Find - Replace operation. If for some reason you don't want
to simply Select All and click Italic, you can open the Replace panel
(Ctrl-H, though it's not impossible that they've changed it in 2007),
type a space in the upper box; place the cursor in the lower box, type
a space, click More, click Format, choose Font, select Italic, then
either go ahead and click Replace All, or test it on one example with
Find Next and Replace.
 
G

grammatim

You appear to be at home in VBA, which I know nothing about, but I can
offer a way to do it fairly quickly by hand.

Do a Find where the search item is nothing but Format > Font > Italic;
after you Find the first occurrence, close the Find window (you'll use
the Find Down arrow at the bottom of the vertical scroll bar from now
on). It Finded the first italicized word. If this is the beginning of
one of the phrases you need to fix, Shift-click at the end of the last
word you want included in the phrase, to select the whole phrase, and
click Italic twice (or press Ctrl-I twice). The first click will de-
italicize the word that you Finded, the second one will italicize the
phrase you selected.

Click the Find Down arrow, and repeat.

Thanks for your response, but the entire document is not in italics, just
some phrases and sentences, as in a typical publication (italicized book
titles, quotes, etc.), with the rest normal non-italicized. I don't want to
turn the whole document into italics, I just want to get the italicized
phrases and sentences to be italicized in their entirety, instead of
italicized words broken up with NONitalicized spaces.

Example:

The favorite book among young readers is <italics start>Jack<italics stop>
<italics start>and<italics stop> <italics start>the<italics stop> <itsalics
start>Beanstalk<italics stop>

I'm using the <italics start> and <italics stop> becuase I'm posting in
plain text. But you can see that the problem, as specified in my first
post, is that within the italicized phrase, which looks fine when printed,
there are nonitalicized spaces (I don't know how that happened, but it did).




I'm just curious here, and thought I'd ask.
I've discovered that a lot of the italicized phrases in my VERY long Word
document have the WORDS in italics, but for some reason the spaces
between
the words are NOT. So, when I run my macro to place all italicized
phrases
inside html tags, I get every word enclosed in the tags instead of the
entire sentence/phrase.
Is there any way to:
1) Fix the non-formatted SPACES between words that are italicized in
Word
before running the macro OR
2) Fixing it within the code of the macro.
Here's what I have for the bracket thing:
Set MyRange = ActiveDocument.Content
With MyRange.Find
.ClearFormatting
.Font.Italic= True
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = "<em>^&</em>]"
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
End With
Thanks for any ideas or comments on this, and for taking the time
I'm no professional, just stopped in to see if my question has been
addressed yet, so maybe I'm missing something -- but this sounds like
a simple Find - Replace operation. If for some reason you don't want
to simply Select All and clickItalic, you can open the Replace panel
(Ctrl-H, though it's not impossible that they've changed it in 2007),
type a space in the upper box; place the cursor in the lower box, type
a space, click More, click Format, choose Font, selectItalic, then
either go ahead and click Replace All, or test it on one example with
Find Next and Replace.-
 
C

CompleteNewb

Thanks again for your attempts to helpl, they are much appreciated, but this
document is hundreds of pages long, with very many italicized items. What
I'm trying to do is automate this in some way, since doing it manually would
take many hours.

Thanks again


grammatim said:
You appear to be at home in VBA, which I know nothing about, but I can
offer a way to do it fairly quickly by hand.

Do a Find where the search item is nothing but Format > Font > Italic;
after you Find the first occurrence, close the Find window (you'll use
the Find Down arrow at the bottom of the vertical scroll bar from now
on). It Finded the first italicized word. If this is the beginning of
one of the phrases you need to fix, Shift-click at the end of the last
word you want included in the phrase, to select the whole phrase, and
click Italic twice (or press Ctrl-I twice). The first click will de-
italicize the word that you Finded, the second one will italicize the
phrase you selected.

Click the Find Down arrow, and repeat.

Thanks for your response, but the entire document is not in italics, just
some phrases and sentences, as in a typical publication (italicized book
titles, quotes, etc.), with the rest normal non-italicized. I don't want
to
turn the whole document into italics, I just want to get the italicized
phrases and sentences to be italicized in their entirety, instead of
italicized words broken up with NONitalicized spaces.

Example:

The favorite book among young readers is <italics start>Jack<italics
stop>
<italics start>and<italics stop> <italics start>the<italics stop>
<itsalics
start>Beanstalk<italics stop>

I'm using the <italics start> and <italics stop> becuase I'm posting in
plain text. But you can see that the problem, as specified in my first
post, is that within the italicized phrase, which looks fine when
printed,
there are nonitalicized spaces (I don't know how that happened, but it
did).




I'm just curious here, and thought I'd ask.
I've discovered that a lot of the italicized phrases in my VERY long
Word
document have the WORDS in italics, but for some reason the spaces
between
the words are NOT. So, when I run my macro to place all italicized
phrases
inside html tags, I get every word enclosed in the tags instead of the
entire sentence/phrase.
Is there any way to:
1) Fix the non-formatted SPACES between words that are italicized in
Word
before running the macro OR
2) Fixing it within the code of the macro.
Here's what I have for the bracket thing:
Set MyRange = ActiveDocument.Content
With MyRange.Find
.ClearFormatting
.Font.Italic= True
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = "<em>^&</em>]"
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
End With
Thanks for any ideas or comments on this, and for taking the time
I'm no professional, just stopped in to see if my question has been
addressed yet, so maybe I'm missing something -- but this sounds like
a simple Find - Replace operation. If for some reason you don't want
to simply Select All and clickItalic, you can open the Replace panel
(Ctrl-H, though it's not impossible that they've changed it in 2007),
type a space in the upper box; place the cursor in the lower box, type
a space, click More, click Format, choose Font, selectItalic, then
either go ahead and click Replace All, or test it on one example with
Find Next and Replace.-
 
Ad

Advertisements

G

Greg Maxey

Very, very limited testing, but this may do:

Sub ScratchMacro()
Dim oWord As Range
Dim oRng As Word.Range
For Each oWord In ActiveDocument.Range.Words
On Error GoTo Err_Handler
If oWord.Font.Italic = True And oWord.Next.Font.Italic = True Then
Set oRng = oWord
oRng.Start = oWord.End - 1
oRng.End = oWord.Next.Start
oRng.MoveStartWhile Cset:=Chr(32), Count:=-1
oRng.Font.Italic = True
End If
Next oWord
Err_Handler:
End Sub


Thanks again for your attempts to helpl, they are much appreciated, but this
document is hundreds of pages long, with very many italicized items. What
I'm trying to do is automate this in some way, since doing it manually would
take many hours.

Thanks again




You appear to be at home in VBA, which I know nothing about, but I can
offer a way to do it fairly quickly by hand.
Do a Find where the search item is nothing but Format > Font > Italic;
after you Find the first occurrence, close the Find window (you'll use
the Find Down arrow at the bottom of the vertical scroll bar from now
on). It Finded the first italicized word. If this is the beginning of
one of the phrases you need to fix, Shift-click at the end of the last
word you want included in the phrase, to select the whole phrase, and
click Italic twice (or press Ctrl-I twice). The first click will de-
italicize the word that you Finded, the second one will italicize the
phrase you selected.
Click the Find Down arrow, and repeat.
Thanks for your response, but the entire document is not in italics, just
some phrases and sentences, as in a typical publication (italicized book
titles, quotes, etc.), with the rest normal non-italicized. I don't want
to
turn the whole document into italics, I just want to get the italicized
phrases and sentences to be italicized in their entirety, instead of
italicized words broken up with NONitalicized spaces.
Example:
The favorite book among young readers is <italics start>Jack<italics
stop>
<italics start>and<italics stop> <italics start>the<italics stop>
<itsalics
start>Beanstalk<italics stop>
I'm using the <italics start> and <italics stop> becuase I'm posting in
plain text. But you can see that the problem, as specified in my first
post, is that within the italicized phrase, which looks fine when
printed,
there are nonitalicized spaces (I don't know how that happened, but it
did).

I'm just curious here, and thought I'd ask.
I've discovered that a lot of the italicized phrases in my VERY long
Word
document have the WORDS in italics, but for some reason the spaces
between
the words are NOT. So, when I run my macro to place all italicized
phrases
inside html tags, I get every word enclosed in the tags instead of the
entire sentence/phrase.
Is there any way to:
1) Fix the non-formatted SPACES between words that are italicized in
Word
before running the macro OR
2) Fixing it within the code of the macro.
Here's what I have for the bracket thing:
Set MyRange = ActiveDocument.Content
With MyRange.Find
.ClearFormatting
.Font.Italic= True
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = "<em>^&</em>]"
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.ClearFormatting
End With
Thanks for any ideas or comments on this, and for taking the time
I'm no professional, just stopped in to see if my question has been
addressed yet, so maybe I'm missing something -- but this sounds like
a simple Find - Replace operation. If for some reason you don't want
to simply Select All and clickItalic, you can open the Replace panel
(Ctrl-H, though it's not impossible that they've changed it in 2007),
type a space in the upper box; place the cursor in the lower box, type
a space, click More, click Format, choose Font, selectItalic, then
either go ahead and click Replace All, or test it on one example with
Find Next and Replace.-- Hide quoted text -

- Show quoted text -
 
Ad

Advertisements


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