Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.formatting.longdocs
homeologica
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

In a document I must convert only the first word, (entry), of a paragraph.
This first word have a specific font different to rest of the paragraph.

Can I do this?

Thanks.

Alejandro Fernandez


  #2   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Greg Maxey
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Doesn't change the style, but does change the font of the first word.

Sub Test()
Dim oPar
For Each oPar In ActiveDocument.Paragraphs
oPar.Range.Words.First.Font.Name = "Courier New"
Next
End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

homeologica wrote:
In a document I must convert only the first word, (entry), of a
paragraph. This first word have a specific font different to rest of
the paragraph.

Can I do this?

Thanks.

Alejandro Fernandez



  #3   Report Post  
Posted to microsoft.public.word.formatting.longdocs
homeologica
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Thanks Greg. I need to change the style because headings must have StyleRef
DefinedStyle. Only First words must appear in this Headings


  #4   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Greg Maxey
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Try:

Sub Test()
Dim oPar
For Each oPar In ActiveDocument.Paragraphs
oPar.Range.Words.First.Select
Selection.Style = ActiveDocument.Styles("Heading 1 Char")
Next
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

homeologica wrote:
Thanks Greg. I need to change the style because headings must have
StyleRef DefinedStyle. Only First words must appear in this Headings



  #5   Report Post  
Posted to microsoft.public.word.formatting.longdocs
homeologica
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Greg.

I am trying some modifications in your code. I think this is very close to
the real solution.

Many thanks.

Alejandro Fernandez




  #6   Report Post  
Posted to microsoft.public.word.formatting.longdocs
homeologica
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Greg
I need to select the first word of each paragraph which be a word formattaed
as Tahoma 11 points font . Not other first words. This code converts to new
style paragraph marks too. I must avoid this.

So, the statement

oPar.Range.Words.First.Select

Must be changed or validated

Thank you for your valuable help.

Alejandro Fernandez



  #7   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Greg Maxey
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Try:
Sub Test()
Dim oPar
For Each oPar In ActiveDocument.Paragraphs
oPar.Range.Words.First.Select
Selection.MoveEnd wdCharacter, -1
With Selection
If .Font.Name = "Tahoma" And .Font.Size = "11" Then
.Style = ActiveDocument.Styles("Heading 1")
End If
End With
Next
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
"homeologica" wrote in message
...
Greg
I need to select the first word of each paragraph which be a word
formattaed
as Tahoma 11 points font . Not other first words. This code converts to
new
style paragraph marks too. I must avoid this.

So, the statement

oPar.Range.Words.First.Select

Must be changed or validated

Thank you for your valuable help.

Alejandro Fernandez





  #8   Report Post  
Posted to microsoft.public.word.formatting.longdocs
homeologica
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Greg:

Forgive to send you files but as my document is very complex I send you a
sample.
(The original has 1400 pages.)

With best regards and thank you your your help.

Alejandro Fernandez






Attached Files
File Type: zip psiquismomin.zip (66.1 KB, 117 views)
  #9   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Daiya Mitchell
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Sideways approach--test on a COPY of the doc.

Assuming what you want to change is the only stuff formatted in Tahoma 11pt,
use Find and Replace?

Find: an empty box, click More, then Format in the F&R dialog, Font to
format the empty box as 11pt Tahoma

Replace: an empty box, click Format in the F&R dialog, Style to format the
empty box as desired style.


On 11/20/05 7:10 PM, "homeologica" wrote:

In a document I must convert only the first word, (entry), of a paragraph.
This first word have a specific font different to rest of the paragraph.

Can I do this?

Thanks.

Alejandro Fernandez



--
Daiya Mitchell, MVP Mac/Word
Word FAQ: http://www.word.mvps.org/
MacWord Tips: http://www.word.mvps.org/MacWordNew/
What's an MVP? A volunteer! Read the FAQ: http://mvp.support.microsoft.com/

  #10   Report Post  
Posted to microsoft.public.word.formatting.longdocs
homeologica
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Thanks Daiya:

Your procedure format all paragraph instead the first word (Tahoma 11pt)

This word must appear in each page heading.

Alejandro Fernandez




  #11   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Daiya Mitchell
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Hi Alejandro,

You did say that the word you need to apply the style to already has a
different font from the rest, right? Because that should work, if those
words are the only ones formatted in that font--I hadn't tested it before
but I just did and it works here (MacWord 2004).

However, in the Replace box, the style you choose *must* be a character
style (denoted by underscored "a"), not a paragraph style (denoted by ¶ in
the list in the Style dialog).

If you use a paragraph style for the Replace setting, then the entire
paragraph does change. But it works if you use a character style, and a
character style is what you want for dictionary-style headings anyhow.

Is your DefinedStyle a paragraph or a character style?


On 11/21/05 9:12 AM, "homeologica" wrote:

Thanks Daiya:

Your procedure format all paragraph instead the first word (Tahoma 11pt)

This word must appear in each page heading.

Alejandro Fernandez



--
Daiya Mitchell, MVP Mac/Word
Word FAQ: http://www.word.mvps.org/
MacWord Tips: http://www.word.mvps.org/MacWordNew/
What's an MVP? A volunteer! Read the FAQ: http://mvp.support.microsoft.com/

  #12   Report Post  
Posted to microsoft.public.word.formatting.longdocs
homeologica
 
Posts: n/a
Default Replacing style of the first word of a paragraph only

Yes Daiya, you're right. Character style works fine.

Thanks a lot. Thanks to Greg too.

Alejandro Fernandez


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set right and left alignment on the same line in Word? Matador Page Layout 1 November 9th 05 09:32 PM
Envelope Address GR New Users 5 April 24th 05 09:48 PM
Macros - Keyboard Commands Janet Microsoft Word Help 6 April 11th 05 05:28 AM
In Word, how can I see all files (*.*) in "save as"? citizen53 New Users 8 April 4th 05 04:56 PM
Font properties of table styles versus paragraph styles Bob S Tables 3 February 8th 05 02:13 PM


All times are GMT +1. The time now is 12:06 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"