Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I was attempted to write a macro (in Word 2003 SP2) which would apply
a paragraph style to a line based on its indentation. So I thought I would start as usual by recording the macro then editing it down. However, when I tried a Find, with the "Find What" field empty, but with the parameter Format-Paragraph-Indentation Left set to 5.71cm, on a document containing a line with such an indentation, it doesn't find it. I even tried it with a "Find What" field value of "heading", with a line in the document containing the word "heading" and with an indentation of 5.71cm. This also didn't work. Is there a correct way to do this? Thanks, P. |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
If you were using the macro recorder, it's buggy. It records the Find, but
neglects to include anything about the formatting you specified. The article http://www.word.mvps.org/FAQs/Macros...ordedMacro.htm explains how to modify the macro. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Paul Moloney wrote: I was attempted to write a macro (in Word 2003 SP2) which would apply a paragraph style to a line based on its indentation. So I thought I would start as usual by recording the macro then editing it down. However, when I tried a Find, with the "Find What" field empty, but with the parameter Format-Paragraph-Indentation Left set to 5.71cm, on a document containing a line with such an indentation, it doesn't find it. I even tried it with a "Find What" field value of "heading", with a line in the document containing the word "heading" and with an indentation of 5.71cm. This also didn't work. Is there a correct way to do this? Thanks, P. |
#3
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
On Sep 28, 5:29 pm, "Jay Freedman" wrote:
If you were using the macro recorder, it's buggy. It records the Find, but neglects to include anything about the formatting you specified. The articlehttp://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htmexplains how to modify the macro. Hi Jay, The problem isn't related to re-running the macro; it's to do with the Find command. Note the above behaviour happens even when I'm not recording a macro; the Find command simply won't find text based on its paragraph indentation. Regards, P. |
#4
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I also tried creating a macro from scratch, without recording. This
_should_ work as far as I know, but doesn't find anything: Sub Macro1() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .ParagraphFormat.LeftIndent = CentimetersToPoints(10) .Replacement.ParagraphFormat.LeftIndent = CentimetersToPoints(1) .Forward = True .Wrap = wdFindAsk .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub |
#5
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I can affirm that Find does work when searching for Indent formatting (with
Find what: blank, or with Find what: containing any text with the corresponding Indent applied). So... the question is WHY it's not working for you. Try starting Word with the /a switch (start - run - winword.exe /a). Set up a simple scenario -- 1 cm left indent (for example), and see if Find finds it. -- Herb Tyson MS MVP Author of the Word 2007 Bible Blog: http://word2007bible.herbtyson.com Web: http://www.herbtyson.com "Paul Moloney" wrote in message ups.com... On Sep 28, 5:29 pm, "Jay Freedman" wrote: If you were using the macro recorder, it's buggy. It records the Find, but neglects to include anything about the formatting you specified. The articlehttp://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htmexplains how to modify the macro. Hi Jay, The problem isn't related to re-running the macro; it's to do with the Find command. Note the above behaviour happens even when I'm not recording a macro; the Find command simply won't find text based on its paragraph indentation. Regards, P. |
#6
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
After much messing around, I finally discovered why this wasn't
working for me; it may be related to the way Word rounds numbers when displaying them. When I imported the text I wanted to manipulate into a fresh Word document, the parameter left indent for certain lines shows up as 0.63cm (roughly 1/4 inch) when I select the text and displayed Format- Paragraph. So my macro searched for lines with an left indent of 0.63cm; this didn't work. However, a left-indent of 0.635 _did_ work. The same for lines of 1.9cm (~3/4 inch); searching for lines of 1.9cm didn't work, but 1.905cm did. So the number displayed for the indentation in the Format-Paragraph box for imported text appears to be a rounded value rather than the actual value. Hope this is of some use to someone, Regards, P. |
#7
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Indeed, 1/4 in equals exactly 0.635 cm; and 3/4 in = 1.905 cm.
-- Stefan Blom Microsoft Word MVP "Paul Moloney" wrote in message oups.com... After much messing around, I finally discovered why this wasn't working for me; it may be related to the way Word rounds numbers when displaying them. When I imported the text I wanted to manipulate into a fresh Word document, the parameter left indent for certain lines shows up as 0.63cm (roughly 1/4 inch) when I select the text and displayed Format- Paragraph. So my macro searched for lines with an left indent of 0.63cm; this didn't work. However, a left-indent of 0.635 _did_ work. The same for lines of 1.9cm (~3/4 inch); searching for lines of 1.9cm didn't work, but 1.905cm did. So the number displayed for the indentation in the Format-Paragraph box for imported text appears to be a rounded value rather than the actual value. Hope this is of some use to someone, Regards, P. |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
reset style that is based upon another style | Microsoft Word Help | |||
Finding all selected instances of a style | Microsoft Word Help | |||
Using heading style and body text in same paragraph | Microsoft Word Help | |||
Style for Following Paragraph Doesn't Work | Microsoft Word Help | |||
selecting text based on 'style' | Microsoft Word Help |