Determin which paragraph the selection start is in? 
Author Message
 Determin which paragraph the selection start is in?

Hi. Can someone tell me how I can detemin in what paragraph
my insertion point is?

If it is say in Activedocument.Paragraphs(3) I want to have a
message about this. If the insertion point is at the very end of
the activedocument, I'd like to get noticed of that. A msgbox
message will do.

Thanks for helping.

Regards
Jan



Wed, 28 Sep 2005 21:43:23 GMT  
 Determin which paragraph the selection start is in?
The only way to prompt a msgbox to upon a selection change in yr
document is to use a WindowSelectionChange event of the Application object.

In below sequence, two ways of determining the IP (insertion point)

Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
If Sel.Range.EndOf(wdStory) = 0 Then
    MsgBox "End of document"
Else
    MsgBox "Paragraph: " & ActiveDocument.Range(0, _
        Sel.Paragraphs(1).Range.End).Paragraphs.Count
End If
End Sub

To raise the eventhandler up the application level:

Look up in VBA help topic
Application Object (or Application Events)

Or look here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwo...
ml/wdwordevnt.asp

Or look here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odeo...

Krgrds,
Perry



Quote:
> Hi. Can someone tell me how I can detemin in what paragraph
> my insertion point is?

> If it is say in Activedocument.Paragraphs(3) I want to have a
> message about this. If the insertion point is at the very end of
> the activedocument, I'd like to get noticed of that. A msgbox
> message will do.

> Thanks for helping.

> Regards
> Jan



Thu, 29 Sep 2005 01:00:51 GMT  
 Determin which paragraph the selection start is in?
Hi, Perry.
Thank you very much. Your solution really solved a problem
that I now have worked with for hours.

In vba I do a loop in the document where I am supposed to
delete several paragraphs. However, the loop will not stop
until I reach the next built in Word Heading1 style or when
I know I am at the end of the document.

This is part of the code inside the loop:
------------------------------------------------------------------
With Selection
    .MoveEnd unit:=wdParagraph, Count:=1
    intPgraph = ActiveDocument.Range(0, .Paragraphs(1) _
                                         .Range.End).Paragraphs.Count
    .Delete

' intPgraph GIVES YOU THE PARAGRAPH NUMBER I THE
' DOKUMENT WHERE THE CURSOR IS AND...
' DELETING ONE PARAGRAPH MAKES ActiveDocument.Paragraphs.Count.
' LESS THAN intPgraph

    If ActiveDocument.Paragraphs.Count <  intPgraph Then Exit Do
End With
' ...moore code...
-------------------------------------------------------------------

Danke Wel? Thank you again.

Jan
(ps. Ik prate eine kleine beitje Nederlands, but do not write nl as u see.
;-)   )


Quote:
> The only way to prompt a msgbox to upon a selection change in yr
> document is to use a WindowSelectionChange event of the Application
object.

> In below sequence, two ways of determining the IP (insertion point)

> Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
> If Sel.Range.EndOf(wdStory) = 0 Then
>     MsgBox "End of document"
> Else
>     MsgBox "Paragraph: " & ActiveDocument.Range(0, _
>         Sel.Paragraphs(1).Range.End).Paragraphs.Count
> End If
> End Sub

> To raise the eventhandler up the application level:

> Look up in VBA help topic
> Application Object (or Application Events)

> Or look here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwo...
Quote:
> ml/wdwordevnt.asp

> Or look here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odeo...

- Show quoted text -

Quote:
> /deconworkingwithevents.asp

> Krgrds,
> Perry



> > Hi. Can someone tell me how I can detemin in what paragraph
> > my insertion point is?

> > If it is say in Activedocument.Paragraphs(3) I want to have a
> > message about this. If the insertion point is at the very end of
> > the activedocument, I'd like to get noticed of that. A msgbox
> > message will do.

> > Thanks for helping.

> > Regards
> > Jan



Thu, 29 Sep 2005 02:26:27 GMT  
 Determin which paragraph the selection start is in?
(ps. Ik prate eine kleine beitje Nederlands, but do not write nl as u see.
;-)   )

That's always worth a "dank je wel" in return !
Chrs
PdL



Quote:
> Hi, Perry.
> Thank you very much. Your solution really solved a problem
> that I now have worked with for hours.

> In vba I do a loop in the document where I am supposed to
> delete several paragraphs. However, the loop will not stop
> until I reach the next built in Word Heading1 style or when
> I know I am at the end of the document.

> This is part of the code inside the loop:
> ------------------------------------------------------------------
> With Selection
>     .MoveEnd unit:=wdParagraph, Count:=1
>     intPgraph = ActiveDocument.Range(0, .Paragraphs(1) _
>                                          .Range.End).Paragraphs.Count
>     .Delete

> ' intPgraph GIVES YOU THE PARAGRAPH NUMBER I THE
> ' DOKUMENT WHERE THE CURSOR IS AND...
> ' DELETING ONE PARAGRAPH MAKES ActiveDocument.Paragraphs.Count.
> ' LESS THAN intPgraph

>     If ActiveDocument.Paragraphs.Count <  intPgraph Then Exit Do
> End With
> ' ...moore code...
> -------------------------------------------------------------------

> Danke Wel? Thank you again.

> Jan
> (ps. Ik prate eine kleine beitje Nederlands, but do not write nl as u see.
> ;-)   )



> > The only way to prompt a msgbox to upon a selection change in yr
> > document is to use a WindowSelectionChange event of the Application
> object.

> > In below sequence, two ways of determining the IP (insertion point)

> > Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
> > If Sel.Range.EndOf(wdStory) = 0 Then
> >     MsgBox "End of document"
> > Else
> >     MsgBox "Paragraph: " & ActiveDocument.Range(0, _
> >         Sel.Paragraphs(1).Range.End).Paragraphs.Count
> > End If
> > End Sub

> > To raise the eventhandler up the application level:

> > Look up in VBA help topic
> > Application Object (or Application Events)

> > Or look here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwo...
Quote:
> > ml/wdwordevnt.asp

> > Or look here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odeo...

- Show quoted text -

Quote:
> > /deconworkingwithevents.asp

> > Krgrds,
> > Perry



> > > Hi. Can someone tell me how I can detemin in what paragraph
> > > my insertion point is?

> > > If it is say in Activedocument.Paragraphs(3) I want to have a
> > > message about this. If the insertion point is at the very end of
> > > the activedocument, I'd like to get noticed of that. A msgbox
> > > message will do.

> > > Thanks for helping.

> > > Regards
> > > Jan



Thu, 29 Sep 2005 05:49:33 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Delete range of paragraphs based on start text of paragraphs

2. Selection of paragraph styles in one go

3. Delete last paragraph mark in a selection

4. selection of a paragraph

5. paragraph selection query

6. Paragraph selection

7. Need Help Extending Selection by Paragraphs

8. Is Selection a Paragraph Mark?

9. How to set starting paragraph number?

10. select paragraph, prompt, select next paragraph

11. Linking a paragraph to another paragraph.

12. I am starting out and need some help

 

 
Powered by phpBB® Forum Software