Re: Grabbing previous numbered para

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: zivd (anonymous_at_discussions.microsoft.com)
Date: 09/04/04


Date: Sat, 4 Sep 2004 12:01:33 -0700

Thanks, Helmet. I'll give it a try!

>-----Original Message-----
>Hi,
>pretty, pretty complicated!
>It is assumed, that you search a selection, not a range.
>If you have found, what you have been searching for,
>then the selection is in 1 paragraph, probably.
>But I took care of that, too. (Msgbox)
>Then you have to check, whether this paragraph has an
automatic
>numbering. See Function IsAutoNumberedParagraph.
>If so, do nothing, otherwise loop through all preceeding
paragraphs
>backwards and check, whether the actual paragraph is
autonumbered.
>I used 0 for false, -1 for true and 9999999 for
undefinded, as usual.
>Good Luck, and remove the bugs and typos, I left behind.
>---
>Sub Test464()
>Dim i As Integer
>Dim oRng As Range
>Set oRng = Selection.Paragraphs(1).Range
>If IsAutoNumberedParagraph(oRng) = -1 Then
> Exit Sub
>End If
>oRng.Start = 0
>oRng.End = Selection.End
>For i = oRng.Paragraphs.Count To 1 Step -1
> If IsAutoNumberedParagraph(oRng.Paragraphs(i).Range)
Then
> oRng.Paragraphs(i).Range.Select
> Exit Sub
> End If
>Next
>End Sub
>Function IsAutoNumberedParagraph(oRng As Range) As Long
>Dim iLst As Integer
>If oRng.Paragraphs.Count > 1 Then
> MsgBox "More than 1 paragraph selected"
> IsAutoNumberedParagraph = 9999999
> Exit Function
>End If
>If oRng.ListParagraphs.Count = 0 Then
> IsAutoNumberedParagraph = 0
> Exit Function
>End If
>iLst = oRng.ListFormat.ListType
> Select Case iLst
> Case 1, 4, 5, 6: IsAutoNumberedParagraph = -1
> Case Else: IsAutoNumberedParagraph = 0
> End Select
>End Function
>Sub test111()
>MsgBox IsAutoNumberedParagraph(Selection.Range)
>End Sub
>---
>Greetings from Bavaria, Germany
>Helmut Weber, MVP
>"red.sys" & chr(64) & "t-online.de"
>Word XP, Win 98
>
>
>
>
>.
>



Relevant Pages

  • Printing selected reports from multi select list box
    ... However for the tutor group list, ... 'If no classes selected then Exit Sub ... 'If user chooses No, return to selection box. ... Dim ControlName As String ...
    (microsoft.public.access.formscoding)
  • Re: Help With Code
    ... am I correct if I would say you use Dim ... object (like the name of a paragraph style in your document)? ... > Greg Maxey/Word MVP ... >>> which may lead beginners to stick to the selection. ...
    (microsoft.public.word.vba.general)
  • Re: Printing selected reports from multi select list box
    ... 'If no classes selected then Exit Sub ... 'If user chooses No, return to selection box. ... 'If user chooses Yes, continue printing ... Dim ControlName As String ...
    (microsoft.public.access.formscoding)
  • Re: Printing selected reports from multi select list box
    ... 'If no classes selected then Exit Sub ... 'If user chooses No, return to selection box. ... 'If user chooses Yes, continue printing ... Dim ControlName As String ...
    (microsoft.public.access.formscoding)
  • Combo box wont change selection?
    ... this.....if i choose the 1st or last sheet and select a cell there is ... the cell that was previously used in a selection on the first or last ... Dim myrange As Range ... 'Exit Sub ...
    (microsoft.public.excel.programming)