Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting Current Paragraph Index (Word 2000)

    ActiveDocument.Paragraphs(2).Style

    returns the style name of the second paragraph of the document.

    but say I want to manipulate/query the paragraph before or after the current paragraph. Is there a way to get the current paragraphs index so that one could do:

    ActiveDocument.Paragraphs(me+1).Style

    Thanks

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting Current Paragraph Index (Word 2000)

    Guy,

    You did all this stuff:

    Wrote Take Word for Windows to the Edge.
    Developer of ScriptWright, BookWright, and PlayWright -- add-ins for Word for Windows.

    But you're *not* a member of the famous wine family???

    Anyway, to answer your question: Yes. Function below:

    Function ParagraphNumber() As Integer
    'This gives you the index number of the current paragraph
    ParagraphNumber = ActiveDocument.Range(Start:=0, End:=Selection.Paragraphs(1).Range.End).Paragraphs .count
    'MsgBox "The current paragraph number is: " & CStr(GetParagraphNumber)
    End Function

    The credit goes to some genius around here. I forget who.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Getting Current Paragraph Index (Word 2000)

    Kevin,

    Should CStr(GetParagraphNumber) not be CStr(ParagraphNumber) ?

    or just plain ParagraphNumber.

    (or else maybe ParagraphNumber = should be GetParagraphNumber =)

    Andrew

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting Current Paragraph Index (Word 2000)

    Well, Ok. As you deciphered, there is a commented line that bears the OLD name of the function (GetParagraphNumber) which differs from the current name (ParagraphNumber). I pasted quick and dirty.

    If the msgbox is to work, remove GET.

    Did you ever work for the Irish equivalent of our IRS? You don't miss a thing...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting Current Paragraph Index (Word 2000)

    >>But you're *not* a member of the famous wine family???<<

    Sadly, not.

    Thanks for the function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •