VBA CODE FOR FORMATTING TEXT WHICH IS TEXT PLACEHOLDER IN TITLE AND CONTENT LAYOUT IN POWER POINT

Dilpreet Singh
Dilpreet Singh used Ask the Experts™
on
Dear Team,

I have the below vba code to insert bullets with customize formats and alignment. Now I am looking forward to the incorporate the following below mentioned actions  in the code .

Please note that slide contains 2 text placeholder one for the Title and other for text


1. Reposition my text placeholder having (Top=75, Left=90,Width=739 and Height may vary depending on text.To have more clarity for the position of text placeholder I have appended below the image of shape dimensions from Microsoft power point 2016.


2. the text inside the placeholder should be calibri , size 12 & color (R=89,G=89,B=89)

For the size and margins to be freezed I am attaching an image for better clarity.



I need to collate this action with the below mentioned codes to have alignment of text and bullets


Sub Mybullets()

Dim pghcnt As Integer

With ActiveWindow.Selection.TextRange

.ParagraphFormat.bullet.Font.Name = "Wingdings"

.ParagraphFormat.bullet.Character = 167

.ParagraphFormat.Alignment = ppAlignJustify

.ParagraphFormat.bullet.Font.Color = RGB(89, 89, 89)

.ParagraphFormat.bullet.RelativeSize = 0.75


End With

For pghcnt = 1 To Windows(1).Selection.TextRange.Paragraphs.Count

Windows(1).Selection.TextRange.Paragraphs(pghcnt).IndentLevel = 1

With Windows(1).Selection.ShapeRange.TextFrame.Ruler

.Levels(1).FirstMargin = 7

.Levels(1).LeftMargin = 20

End With

Next

End Sub

Open in new window

Further the layout contains title and content placeholder.

Please help me to collate the text part as well.

Thanks in advance

Regards
Dilpreet Singh
content.PNG
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
John WilsonCEO PowerPoint Alchemy

Commented:
First you need to say which version of Office. The code you have used to set the indents is legacy code from 2003 if you have a later version you should really use the new code for textframe2.

Using legacy code try this

Sub Set_Bullet_Position()
Dim osld As Slide
Dim oshp As Shape
On Error Resume Next
Set osld = ActiveWindow.Selection.SlideRange(1)
If Not osld Is Nothing Then
For Each oshp In osld.Shapes
If oshp.Type = msoPlaceholder Then

If oshp.PlaceholderFormat.Type = ppPlaceholderObject Then
oshp.Left = 90
oshp.Top = 75
oshp.Width = 739
oshp.TextFrame.TextRange.Font.Color.RGB = RGB(89, 89, 89)
oshp.TextFrame.TextRange.IndentLevel = 1
With oshp.TextFrame.TextRange
.Font.Color.RGB = RGB(89, 89, 89)
.Font.Name = "Calibri"
.Font.Size = 12
.IndentLevel = 1
With .ParagraphFormat
.Bullet.Font.Name = "Wingdings"
.Bullet.Character = 167
.Alignment = ppAlignJustify
.Bullet.Font.Color = RGB(89, 89, 89)
.Bullet.RelativeSize = 0.75
End With
End With
With oshp.TextFrame.Ruler
.Levels(1).FirstMargin = 7
.Levels(1).LeftMargin = 20
End With
End If
End If
Next oshp
Else
MsgBox "Select a slide"
Err.Clear
End If
End Sub

Open in new window

Dilpreet SinghPROGRAMMER

Author

Commented:
Dear Team,

After selecting the text placeholder, The code is not at all working and I am currently working with Microsoft office professional plus 2016..

Please suggest .

Regards
John WilsonCEO PowerPoint Alchemy

Commented:
Do you mean that the slide has Title / Content AND two text Placeholders or something else. Posting a slide somewhere would help.
CEO PowerPoint Alchemy
Commented:
If you are selecting the shape (ot text) then try

Sub Set_Bullet_Position()
Dim osld As Slide
Dim oshp As Shape
On Error Resume Next
Set oshp = ActiveWindow.Selection.ShapeRange(1)
If Not oshp Is Nothing Then
With oshp
oshp.Left = 90
oshp.Top = 75
oshp.Width = 739
With oshp.TextFrame.TextRange
oshp.TextFrame.TextRange.IndentLevel = 1
.Font.Color.RGB = RGB(89, 89, 89)
.Font.Name = "Calibri"
.Font.Size = 12
.IndentLevel = 1
With .ParagraphFormat
.Bullet.Font.Name = "Wingdings"
.Bullet.Character = 167
.Alignment = ppAlignJustify
.Bullet.Font.Color = RGB(89, 89, 89)
.Bullet.RelativeSize = 0.75
End With
End With
With oshp.TextFrame.Ruler
.Levels(1).FirstMargin = 7
.Levels(1).LeftMargin = 20
End With
End With
Else
MsgBox "Nothing appropriate selected"
Err.Clear
End If
End Sub

Open in new window

Dilpreet SinghPROGRAMMER

Author

Commented:
Thanks for your code sir, I was indeed helpful.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial