Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Sun, 28 Sep 2008 13:42:39 -0700 (PDT),    group: microsoft.public.word.vba.general        back       


Text of first paragraph that has been formatted with a user defined heading style to be displayed in a msgBox   
Dear Experts:

Below macro checks whether a user-defined heading style (Heading_IV)
has been applied. If so, it shows the section number of the first
occurence of the custom-defined heading style (Heading_IV) as well as
the corresponding page number of the first occurrence.

It is working fine.

   BUT I also would like the MsgBox to show me
 .... (1) the text of the first occurrence of this user-definded
heading style (Heading_IV) and ...
 .... (2) the paragraph number of the first occurence of this user-
defined heading style (the counting to begin from the section where
the first occurrence of the user-defined heading style has occurred)

Help is very much appreciated. Thank you very much in advance.

Kind Regards, Andreas


Sub FirstOccurrenceUserDefinedHeaderStyle()

Dim rng As range
Dim oRange_Heading_IV As range
Dim nSection_Heading_IV As Long
Dim iPageStart As Integer

Set rng = ActiveDocument.range
    With rng.Find
        .Style = ActiveDocument.Styles("Heading_IV")
        .Forward = True
        .Wrap = wdFindStop
        .Format = True

            If .Execute() Then
               iPageStart = rng.Information(wdActiveEndPageNumber)
               Set oRange_Heading_IV = rng
               nSection_Heading_IV = rng.Sections(1).Index
               MsgBox "The first occurrence of HeadingIVis found on
page " & iPageStart & " and  Section " &  Section_Heading_IV & "."
.....
.....
date: Sun, 28 Sep 2008 13:42:39 -0700 (PDT)   author:   andreas

Re: Text of first paragraph that has been formatted with a user defined heading style to be displayed in a msgBox   
oRange_Heading_IV.Text or rng.Text will show what you want

-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"andreas"  wrote in message 
news:e9036789-a99c-402a-8b83-749fd87f87f4@l64g2000hse.googlegroups.com...
> Dear Experts:
>
> Below macro checks whether a user-defined heading style (Heading_IV)
> has been applied. If so, it shows the section number of the first
> occurence of the custom-defined heading style (Heading_IV) as well as
> the corresponding page number of the first occurrence.
>
> It is working fine.
>
>   BUT I also would like the MsgBox to show me
> .... (1) the text of the first occurrence of this user-definded
> heading style (Heading_IV) and ...
> .... (2) the paragraph number of the first occurence of this user-
> defined heading style (the counting to begin from the section where
> the first occurrence of the user-defined heading style has occurred)
>
> Help is very much appreciated. Thank you very much in advance.
>
> Kind Regards, Andreas
>
>
> Sub FirstOccurrenceUserDefinedHeaderStyle()
>
> Dim rng As range
> Dim oRange_Heading_IV As range
> Dim nSection_Heading_IV As Long
> Dim iPageStart As Integer
>
> Set rng = ActiveDocument.range
>    With rng.Find
>        .Style = ActiveDocument.Styles("Heading_IV")
>        .Forward = True
>        .Wrap = wdFindStop
>        .Format = True
>
>            If .Execute() Then
>               iPageStart = rng.Information(wdActiveEndPageNumber)
>               Set oRange_Heading_IV = rng
>               nSection_Heading_IV = rng.Sections(1).Index
>               MsgBox "The first occurrence of HeadingIVis found on
> page " & iPageStart & " and  Section " &  Section_Heading_IV & "."
> .....
> .....
date: Mon, 29 Sep 2008 12:35:40 +1000   author:   Doug Robbins - Word MVP

Re: Text of first paragraph that has been formatted with a user defined heading style to be displayed in a msgBox   
On Sep 29, 4:35 am, "Doug Robbins - Word MVP"
 wrote:
> oRange_Heading_IV.Text or rng.Text will show what you want
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "andreas"  wrote in message
>
> news:e9036789-a99c-402a-8b83-749fd87f87f4@l64g2000hse.googlegroups.com...
>
>
>
> > Dear Experts:
>
> > Below macro checks whether a user-defined heading style (Heading_IV)
> > has been applied. If so, it shows the section number of the first
> > occurence of the custom-defined heading style (Heading_IV) as well as
> > the corresponding page number of the first occurrence.
>
> > It is working fine.
>
> >   BUT I also would like the MsgBox to show me
> > .... (1) the text of the first occurrence of this user-definded
> > heading style (Heading_IV) and ...
> > .... (2) the paragraph number of the first occurence of this user-
> > defined heading style (the counting to begin from the section where
> > the first occurrence of the user-defined heading style has occurred)
>
> > Help is very much appreciated. Thank you very much in advance.
>
> > Kind Regards, Andreas
>
> > Sub FirstOccurrenceUserDefinedHeaderStyle()
>
> > Dim rng As range
> > Dim oRange_Heading_IV As range
> > Dim nSection_Heading_IV As Long
> > Dim iPageStart As Integer
>
> > Set rng = ActiveDocument.range
> >    With rng.Find
> >        .Style = ActiveDocument.Styles("Heading_IV")
> >        .Forward = True
> >        .Wrap = wdFindStop
> >        .Format = True
>
> >            If .Execute() Then
> >               iPageStart = rng.Information(wdActiveEndPageNumber)
> >               Set oRange_Heading_IV = rng
> >               nSection_Heading_IV = rng.Sections(1).Index
> >               MsgBox "The first occurrence of HeadingIVis found on
> > page " & iPageStart & " and  Section " &  Section_Heading_IV & "."
> > .....
> > .....- Hide quoted text -
>
> - Show quoted text -

Hey Dough,

thank you very much for your quick help. It works. Great! I wonder
whether you also could give me some help with my second requirement on
that macro:

... (2) the paragraph number of the first occurence of this user-
defined heading style (the counting of the paragraph number to begin
from the section where
the first occurrence of the user-defined heading style has occurred)

Thank you vey much in advance. Regards, Andreas
date: Sun, 28 Sep 2008 21:12:18 -0700 (PDT)   author:   andreas

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us