Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Paul Moloney Paul Moloney is offline
external usenet poster
 
Posts: 4
Default Finding text based on paragraph style - doesn't work?

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   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Finding text based on paragraph style - doesn't work?

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   Report Post  
Posted to microsoft.public.word.docmanagement
Paul Moloney Paul Moloney is offline
external usenet poster
 
Posts: 4
Default Finding text based on paragraph style - doesn't work?

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   Report Post  
Posted to microsoft.public.word.docmanagement
Paul Moloney Paul Moloney is offline
external usenet poster
 
Posts: 4
Default Finding text based on paragraph style - doesn't work?

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   Report Post  
Posted to microsoft.public.word.docmanagement
Herb Tyson [MVP] Herb Tyson [MVP] is offline
external usenet poster
 
Posts: 2,936
Default Finding text based on paragraph style - doesn't work?

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   Report Post  
Posted to microsoft.public.word.docmanagement
Paul Moloney[_2_] Paul Moloney[_2_] is offline
external usenet poster
 
Posts: 8
Default Finding text based on paragraph style - doesn't work? - SOLVED

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   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom Stefan Blom is offline
external usenet poster
 
Posts: 8,428
Default Finding text based on paragraph style - doesn't work? - SOLVED

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

Posting Rules

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
reset style that is based upon another style AndrewT Microsoft Word Help 1 October 24th 06 11:40 PM
Finding all selected instances of a style Bothell writer Microsoft Word Help 1 August 16th 06 10:16 PM
Using heading style and body text in same paragraph hoffmanjm Microsoft Word Help 1 June 22nd 06 12:48 AM
Style for Following Paragraph Doesn't Work Joemomma Microsoft Word Help 1 July 21st 05 07:40 PM
selecting text based on 'style' stumped Microsoft Word Help 2 February 2nd 05 05:23 AM


All times are GMT +1. The time now is 09:41 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"