Consulting

Results 1 to 4 of 4

Thread: How to reference a textbox

  1. #1

    How to reference a textbox

    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

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    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:
    [VBA]Slide1.TextBox1.Text="abc"[/VBA]

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

    [VBA]ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text = "abc"[/VBA]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    Guys is there VBA for slides like there is for Sheets in Excel?

    ie

    [VBA]Dim Sht as Worksheet

    For each sht in Application.Worksheets
    Do some action[/VBA]


    Would the following work ?

    [VBA]Dim Sld as Slides

    For each Sld in Application.ActivePresentation
    Do some action[/VBA]

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Of course but the correct vba would be:

    [VBA]Dim osld As Slide
    For Each osld In ActivePresentation.Slides
    'do whatever
    next osld[/VBA]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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