dcsimg
Results 1 to 4 of 4

Thread: PowerPoint 365 - Resize Text Box

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2018
    Posts
    1

    PowerPoint 365 - Resize Text Box

    I'm trying to clean up some PowerPoint presentations and was wanting to use VBA script to quickly/ consistently:

    1.Adjust the height and width of the text box at the top of the slide
    2.Adjust the position of this box
    3.Change the font (not size) in this box

    I'm happy for the starting point to be considered that the text box in question is highlighted and for it just to do one at a time...

    I'm falling at first hurdle given you can't 'record' macros in the current version of PowerPoint... I can't even get it to select the text box.

    Any help would be welcomed!

    TIA

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,819

    Re: PowerPoint 365 - Resize Text Box

    i do not have powerpoint but i would expect it to be something like
    Code:
    with activeslide.shapes("mytextboxname")
      .height = someheight
      .width = somewidth
      .top = 99
      .left = 204
      .font.name = "Arial"
    end with
    change all values to suit
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,541

    Re: PowerPoint 365 - Resize Text Box

    How are you defining "the text box in question?" Does the "one at the top" have a consistent name on each slide?

  4. #4
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,541

    Re: PowerPoint 365 - Resize Text Box

    Mine is named "txtTop" and this is the code I'm using to change the values on each slide:

    Code:
    Sub formatTB()
        Dim pres As Presentation
        Dim sld As Slide
        Dim shp As Shape
        Dim J As Integer
        Dim K As Integer
        
        Set pres = ActivePresentation
        For J = 1 To pres.Slides.Count
            Set sld = pres.Slides(J)
            For K = 1 To sld.Shapes.Count
                If sld.Shapes(K).Name = "txtTop" Then
                    With sld.Shapes(K)
                        .Height = 20
                        .Width = 60
                        .Top = 25
                        .Left = 200
                        .TextFrame2.TextRange.Font.Name = "Arial"
                    End With
                End If
            Next K
            Set sld = Nothing
        Next J
        
    End Sub

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width