PDA

View Full Version : How to reference a textbox



peterwmartin
08-03-2012, 04:20 AM
Hi all,
I have a slide with a textbox i have inserted from the developers tab on slide 1 and when I go to slide 2 etc I want to continue adding text to the textbox.
eg 1st slide I have a sentence then 2nd slide I want to continue adding a sentence to the text already there. However when I go to slide two I cant seem to get it both slides have a textbox called textbox1.
Long winded explenation however can someone please tell me how I reference the textboxs using vba.
Thanks

John Wilson
08-03-2012, 12:56 PM
Thereare two ways to reference an ActivX textbox:

The textbox will be on a slide object whose name you will be able to see selected in the vba editor (project explorer pane) if you right click the textbox > view code. It will look like Slide1 but note Slide1 does not necessarily = the first slide.

You can then use:
Slide1.TextBox1.Text="abc"

If you want to refer directly to a TextBox1 on the first slide in the presentation use:

ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text = "abc"

BatmanFan67
08-14-2012, 06:54 PM
Guys is there VBA for slides like there is for Sheets in Excel?

ie

Dim Sht as Worksheet

For each sht in Application.Worksheets
Do some action


Would the following work ?

Dim Sld as Slides

For each Sld in Application.ActivePresentation
Do some action

John Wilson
08-15-2012, 02:33 AM
Of course but the correct vba would be:

Dim osld As Slide
For Each osld In ActivePresentation.Slides
'do whatever
next osld