Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The PowerPoint 2000 screen shot shows a selection of a part, whole and part paragraph in a text frame.

    The VBA expression "Activewindow.Selectiont.TextRange.Paragraphs.coun t" returns a value of THREE.
    The VBA expression "Activewindow.Selection.TextRange.Characters.Count " returns a value of 30 which confirms my view.

    The VBA expression "Activewindow.Selection.TextRange.Paragraphs(1,1). Text" returns a LEN=7 set of characters which set of characters appears to be "aph 4" followed by a vbCrLf.

    The help screens include this:
    If both Start and Length are omitted, the returned range starts with the first paragraph and ends with the last paragraph in the specified range.
    If Start is specified but Length is omitted, the returned range contains one paragraph.
    If Length is specified but Start is omitted, the returned range starts with the first paragraph in the specified range.
    If Start is greater than the number of paragraphs in the specified text, the returned range starts with the last paragraph in the specified range.
    If Length is greater than the number of paragraphs from the specified starting paragraph to the end of the text, the returned range contains all those paragraphs.


    It seems to me that the .Paragraphs() construct does not function as a WordVBAer would expect.
    It does not return the entire paragraph that holds the selected text, only that portion which is still selected.

    Coupled with my earlier observation ("Length of the selection is zero") this presents a difficulty for the programmer would like to format a selection based on an end-user's "click".
    PowerPoint does not appear to provide the same sense as Word, where one can click to establish the insertion point, and then (as a developer) treat the embracing word, sentence or paragraph as a unit.

    I had expected "Activewindow.Selection.TextRange.Paragraphs(1,1). Text"to return "Paragr aph 4" (& vbCrLf)

    The "Activewindow.Selection.TextRange.Paragraphs.Start " offered a faint ray of hope - .START returns Returns the position of the first character in the specified text range relative to the first character in the shape that contains the text, but there is no counterpart .END property that applies to a TextRange property.

    On the bright side I have discovered that the TextRange object can provide one with the Runs. (A text run consists of a range of characters that share the same font attributes.)
    Attached Images Attached Images
    • File Type: jpg 2.JPG (6.1 KB, 0 views)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    As you have found, the PowerPoint object model is very different from that for Word, despite superficial resemblances.

    The TextRange object doesn't have an End property, but you can add the Start and Length properties to calculate it.


  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    ... you can add the Start and Length properties to calculate it.
    Oooh!
    Why didn't I think of that!
    Thanks for the confirmation.

Posting Permissions

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