Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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 |
#9
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I set right and left alignment on the same line in Word? | Page Layout | |||
Envelope Address | New Users | |||
Macros - Keyboard Commands | Microsoft Word Help | |||
In Word, how can I see all files (*.*) in "save as"? | New Users | |||
Font properties of table styles versus paragraph styles | Tables |