I have two simple macros in MS Word 2010:
Sub Home() ' Bound to C-a :) Selection.HomeKey Unit:=wdLine End Sub Sub End() ' Bound to C-e :) Selection.EndKey Unit:=wdLine End Sub
in the spirit of this old post.
Is there any way of having this type of functionality on PPT? Edit: To be really clear, I want to have
Ctrl-a work the same as
Ctrl-e work the same as
I’ve done a fair amount of VBA on Excel but close to 0 on PPT and can’t figure this out. I was trying the following:
Sub Home() ' First I want to get a reference to the TextForm that spans all ' the text of the current block/shape. The approach below doesnt work ' reliably :( Set Parent = ActiveWindow.Selection.Parent.TextForm Start = ActiveWindow.Selection.TextRange.Start Line = 0 e = 0 Do While (e < Start) ' In this loop I check each line until one of them runs past the start ' of the selection. The cursor should then move to the beginning of this ' line Line = Line + 1 e = e + Parent.Lines(e, 1).Length Loop ' This next line actually moves the cursor to the beginning of the line Parent.Lines(e, 1).Characters(0, 0).Select End Sub
Is there a simpler (i.e., single command like in DOC) way to accomplish this?
I’ve narrowed down the issues to one thing:
How can I get a reference to a
TextRange that encompasses the beginning and end of the line containing the cursor?