#1
|
|||
|
|||
VBA needed for changing all text boxes in presentation
I have this code for changing the location of a single text box:
Sub Macro2(control As IRibbonControl) Dim oShp As Shape On Error Resume Next Set oShp = ActiveWindow.Selection.ShapeRange(1) With oShp .LockAspectRatio = False .Left = 34.5 .Top = 84.5 End With End Sub What I want to do is to do this for all text boxes that contain text (i.e., not shapes that are charts, pictures, etc.) in the entire presentation. Can someone show me how to do this? The codes that I've tried to write just don't work. Thanks! |
#2
|
|||
|
|||
You have a great start. Now you need to go through each shape in each slide in the presentation. There are a few more objects to do this.
Code:
Sub Macro2(control as IRibbonControl) Dim oShp As Shape, oSld As Slide, pst As Presentation, pass As Integer 'On Error Resume Next dont like these, I suggest not to use it without handling 'set the variables Set pst = ActivePresentation 'start the loops For Each oSld In pst.Slides For Each oShp In oSld.Shapes pass = 1 'check if we want to skip the shape If oShp.HasTextFrame = msoFalse Then pass = 0 'we can add as many as we want here in case there is more criteria needed If pass = 1 Then With oShp .LockAspectRatio = False .Left = 34.5 .Top = 84.5 End With End If Next oShp Next oSld End Sub Let me know if you have any other questions. Thanks |
#3
|
|||
|
|||
What is the reason for using (control as IRibbonControl) ?
When you say TextBox do you mean TextBoxes (From Insert TextBox) or Placeholders that may or may not contain text? The code would be quite different. |
#4
|
|||
|
|||
@excelledsoftware: Thank you so much! This will do the trick, I think.
@JohnWilson: The reason for the (control as IRibbonControl) is that ultimately I'm going to make this an add-in after I get the macro itself working correctly. As to your other question, I haven't yet decided whether I want it to work from Insert Textbox or from placeholder; I'll get to that in a bit. Thanks again to both of you! |
#5
|
|||
|
|||
Quote:
The majority of my slides have text box for a title and text box for body text, by using this code, it will change the dimension of all text boxes including title textbox, which causes disorganization or interference of slide elements, as in screenshot 69.png so how to apply this code to text boxes that contain body text only? Thanks |
Tags |
select all, text boxes |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help needed in changing text & line colour please | dazzystar | Word | 2 | 05-27-2021 09:39 AM |
Changing the names of text boxes | catflap | Word | 20 | 05-11-2018 08:57 AM |
Changing the font colour in all text boxes | marqives | Word VBA | 1 | 11-25-2014 06:05 PM |
Changing the placeholder text for drop down boxes | DeadBatteries | Word | 1 | 08-24-2012 09:09 AM |
Quick change for all text boxes in a presentation | tmlander | PowerPoint | 1 | 03-09-2012 01:20 AM |