Re: Getting selected TextRange

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



In article <50s5j4hfa52nejucvlhmi9adskrqma8mit@xxxxxxx>, David Thielen
wrote:
Got it on the bounds - I was missing something there.

But as I put in another post, I get cases where many of the properties
throw an exception. Any idea why that happens?

Not really, as I mentioned below. Unless it's to do with the current
selection not being text. Are you testing for that?

ActiveWindow.Selection.Type will return one of four values, depending on
whether the current selection is Slides, Shapes, Text or nothing.



thanks - dave

On Fri, 28 Nov 2008 14:51:49 -0500, Steve Rindsberg
<abuse@xxxxxxxxxxxxx> wrote:

I'm not sure why you're getting an error in some cases, but if the text
is, for example, center-aligned, the BoundLeft property will change as
you add more and more characters. The text will stay centered and
BoundLeft and .BoundWidth will increase by equal amounts.


For a Selection sel, to get the TextRange, we have found that we need
to do:

TextRange fullText;
if (sel.Type == PpSelectionType.ppSelectionText)
{
Microsoft.Office.Interop.PowerPoint.ShapeRange spRange =
sel.ShapeRange;
Microsoft.Office.Interop.PowerPoint.Shape shapeOn =
spRange[1];
fullText = shapeOn.TextFrame.TextRange;
}

Because sel.TextRange throws an exception when getting some properties
like BoundLeft (when the selection Length == 0) and returns a
different value when there is a length.

Shouldn't both of these TextRanges be the same?

thanks - dave

david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm



david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm



.



Relevant Pages

  • Re: Getting selected TextRange
    ... whether the current selection is Slides, Shapes, Text or nothing. ... BoundLeft and .BoundWidth will increase by equal amounts. ... Windward Reports -- http://www.WindwardReports.com ... Cubicle Wars - http://www.windwardreports.com/film.htm ...
    (microsoft.public.powerpoint)
  • RE: Ok to call Application.get_Selection()?
    ... We get an exception that says COMException ... Cannot create a Selection object when this dialog is active. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.office.developer.com.add_ins)
  • origin of error message
    ... i was trying to create an image using user selection of a file in tix ... Exception exceptions.AttributeError: "PhotoImage instance has no ...
    (comp.lang.python)
  • RE: problem in changing part of a sentence
    ... You originally wrote that you are seeing an exception in your call to ... But when I call "Select" on it the resulted selection will be the ... supplying in your calls to MoveStart and MoveEnd. ...
    (microsoft.public.word.vba.general)
  • RE: problem in changing part of a sentence
    ... it will cause the exception to occur. ... But when I call "Select" on it the resulted selection will be the ... supplying in your calls to MoveStart and MoveEnd. ...
    (microsoft.public.word.vba.general)