I would have a noob question about PowerPoint resizing.
I have a slide in "On screen Show (16:9)" size that I need to resize in "Widescreen" size, which is still 16:9 ratio but not the same dimensions.
So I changed the "Slide Size" option : the pictures are well resized, but the text font size in texboxes has not been changed proportionnaly.
My initial slide looks like this :
before resizing
But after resizing, the text font size in textboxes has not been changed :
after resizing
Would anyone have a solution to resize the same way all the element of a slide, including text ?
Thank you in advance.
I try this VBA code to have all textboxes with the option "Shrink text on overflow" :
Sub Change()
Dim oSlide As Slide
Dim oShape As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
oshape.TextFrame2.AutoSize = MsoAutoSize.msoAutoSizeTextToFitShape
Next oShape
Next oSlide
End Sub
But that unfortunately doesn't work.
Related
it's me and my projects for school again. This time I wanted to insert a video into PowerPoint using file path via WMP ActiveX, so I drew one as follows: (uiMode set to "none")
When the slide show starts, I transfer all data from an Excel file to the presentation, including the paths to the video. Then I hide the WMP with Slide85.WMP.uiMode = "invisible".
When the time comes, I want the WMP to appear at the original size that i drawn and the linked video to play, so I used these codes:
Slide85.WMP_TT.uiMode = "none"
Slide85.WMP_TT.URL = "C:\inetpub\wwwroot\TT2.mp4"
Slide85.WMP_TT.Controls.Play
Already muted the video by changing the settings in the Properties tab.
Then the result came out like this:
The video still plays, but only with sound, which is impossible because I muted the control. No visual images is shown from the video, and the control's dimensions changes too.
As of now I cannot think of any causes to this problem. Please help me, I'd be very grateful.
As mentioned on this Microsoft help page, you have to set height and width parameters in code for the player to reserve the space when triggering uiMode="invisible": Player.uiMode
As an alternative, you can draw the size as you have done, then use VBA to hide or show it on the slide with code like this:
Sub HideWMP()
Dim oSlide As Slide
Dim oShape As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type = msoOLEControlObject Then
oShape.Visible = msoTrue
End If
Next oShape
Next oSlide
End Sub
I am trying to remove extra spaces in text using trim method and with the help of following: How do I remove extra spaces in PPT using VBA?
The problem is, it is changing font color, styling and setting all text in slide to single format/style.
Example:
Slide has blue colored bold title, remaining text is in black. After running above code the title is changing its style (i.e it is changed to black and not bold).
This is a slightly revised version of the code in the linked question that uses TextRange.Replace instead of writing the trimmed text back to the shape. It should maintain the formatting.
Sub Test()
Dim shpTextRng As TextRange
Dim sld As Slide
Dim shp As Shape
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
Set shpTextRng = shp.TextFrame.TextRange
Do While InStr(shpTextRng.Text, " ") > 0
shpTextRng.Replace FindWhat:=" ", ReplaceWhat:=" "
Loop
End If
Next shp
Next sld
End Sub
I am trying to center align the text boxes in a large presentation. Each slide contains various shapes, but only has one text box with text in it, and I would like that text box aligned to the center of the slide. At the moment, I have a line of code that will make the text center aligned within its own text box, but I was wondering if there was a way of making the text box in the middle of the slide?
Sub TextSize()
Dim oSl As Slide
Dim oSh As Shape
With ActivePresentation
For Each oSl In .Slides
For Each oSh In oSl.Shapes
With oSh
If .HasTextFrame Then
If .TextFrame.HasText Then
.TextFrame.TextRange.Font.Size = 26.5
' change the code to make the text box centre aligned to the slide
.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
End If
End If
End With
Next
Next
End With
End Sub
Gopal's pointed you in the right direction. After your code to center the text, add this:
.Left = ActivePresentation.PageSetup.SlideWidth / 2 - .Width / 2
.Top = ActivePresentation.PageSetup.SlideHeight / 2 - .Height / 2
Although not mentioned, but in case you are adding the textboxes on the slide through VBA code (as explained in this documentation), then I guess textboxes do not have a property to directly get aligned to the slide in a particular fashion(in your case centrally).
Having said that, I would also point towards a possible workaround which may be to set the Top and the Left properties of the textboxes in a ratio proportional to the slide's height and width chosen for your presentation.
This I think should centrally align the textboxes.
I have a predefined textbox in a PowerPoint slide, I need to make its corners rounded. Is there any way I can do this using VBA?
This example assumes that the shape you're after is the third shape on slide 1. Adjust accordingly:
Sub Test()
Dim oSh As Shape
Set oSh = ActivePresentation.Slides(1).Shapes(3)
With oSh
.AutoShapeType = msoShapeRoundedRectangle
.Adjustments(1) = 0.25
End With
End Sub
It converts the textbox to a rounded rectangle then sets the corners to be rounded. As far as I know, you cannot round the corners of a regular text box.
I am programatically copying tables and graphs from Excel to PowerPoint.
Ideally, I'd like to center the graphs on the slide and resize them to fit the slide if necessary.
This shouldn't be too hard, and I can check & modify .Top, .Left, .Width, .Height of the shape just fine, but how do I find out the width/height of the slide itself to do the proper positioning?
The following will give you the Height and Width ...
Just divide by 2 :D
Sub a()
Dim a As Presentation
Set a = ActivePresentation
MsgBox a.PageSetup.SlideHeight, a.PageSetup.SlideWidth
End Sub
HTH