PDA

View Full Version : How do i get a handle on currently selected textbox?



sryoung44dd
12-20-2006, 02:59 PM
:banghead: 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

Andy Pope
12-20-2006, 03:10 PM
Hi,

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

sryoung44dd
12-20-2006, 04:47 PM
:clap: 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

Andy Pope
12-21-2006, 02:27 AM
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.

John Wilson
02-24-2007, 12:51 PM
You could add the code to a right click menu.

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