Consulting

Results 1 to 5 of 5

Thread: How do i get a handle on currently selected textbox?

  1. #1

    How do i get a handle on currently selected textbox?

    Hello all,
    I'm new to VBA in PowerPoint. I am finding it very confusing. How do I get a handle on the currently selected textbox?

    I want to create a macro that will select all of the text in the textbox that has the focus and then open the 'Insert HyperLink' dialog.

    Ideally, I would click on the text box, the 'select all' action would run, and the 'Insert HyperLink' dialog box would open.


    Thanks

  2. #2
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    Hi,

    This works in pp2003 when a textbox is selected
    [vba] ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
    Application.CommandBars.FindControl(Id:=1576).Execute[/vba]
    Cheers
    Andy

  3. #3

    Thanks Andy

    This works great.

    However, I need to select the textbox then run the macro. Is there a way to reduce it to one step, maybe by getting the macro to run as soon as I select the textbox?

    Thanks

  4. #4
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    I not sure you could do that.

    What might work is to create a userform that lists all valid controls on slides and then run the code when the listbox choice changes.

    The real problem I see though with this approach is anytime you select something the code would run but what if you select something by mistake?
    Better to run the code on a postive action such as a button click.
    Cheers
    Andy

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    You could add the code to a right click menu.

    see pptalchemy.co.uk for details of how to do this

Posting Permissions

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