TrippyTom
05-06-2008, 08:57 AM
Hi guys....
I have some code that is quite repetitive in many subroutines but wouldn't work as a stand-alone subroutine. Is there a way to call only PART OF a sub in many subs?
Specifically, I'm formatting placeholder text like:
With .ParagraphFormat
.LineRuleWithin = msoTrue
.SpaceWithin = 1
.LineRuleBefore = msoTrue
.SpaceBefore = 0.25
.LineRuleAfter = msoFalse
.SpaceAfter = 0
End With
.Text = "Heading" & vbCr & "Bullet 1" & vbCr & "Bullet 2" & vbCr & "Bullet 3"
.ParagraphFormat.Alignment = ppAlignLeft
.Paragraphs(1, 1).Font.Size = 14
.Paragraphs(1, 1).Font.Color = myHeader
.Paragraphs(2, 3).Font.Size = 14
.Paragraphs(2, 3).Font.Color = myBody
'turn off bullet for Header
.Paragraphs(Start:=1, Length:=1).ParagraphFormat.Bullet.Visible = msoFalse
'bullet format for next 3 paragraphs
.Paragraphs(Start:=2, Length:=3).ParagraphFormat.Bullet.Visible = msoTrue
.Paragraphs(2).IndentLevel = 1
.Paragraphs(3).IndentLevel = 2
.Paragraphs(4).IndentLevel = 3
With .Paragraphs(Start:=2, Length:=1).ParagraphFormat.Bullet
.Visible = msoTrue
With .Font
.Name = "Wingdings 2"
.Color.RGB = myBullets
End With
.Character = 151
End With
With .Paragraphs(Start:=3, Length:=1).ParagraphFormat.Bullet
.Visible = msoTrue
With .Font
.Name = "Arial"
.Color.RGB = myBullets
End With
.Character = 8211
End With
With .Paragraphs(Start:=4, Length:=1).ParagraphFormat.Bullet
.Visible = msoTrue
With .Font
.Name = "Wingdings"
.Color.RGB = myBullets
End With
.Character = 167
.RelativeSize = 0.9
End With
... and the situation where I want to call this varies depending on how many placeholders I have on the slide. Like, for 2 Columns, I would have:
With ActivePresentation.Slides(mySlide)
Set sObj = ActivePresentation.Slides.Add(mySlide + 1, ppLayoutTwoColumnText).Shapes
With sObj.Placeholders(2).TextFrame.TextRange
Call ___mySpecialRoutine___
end with
I'm guessing the answer is no and I'll have to figure out a way to make it a real subroutine. :dunno
I have some code that is quite repetitive in many subroutines but wouldn't work as a stand-alone subroutine. Is there a way to call only PART OF a sub in many subs?
Specifically, I'm formatting placeholder text like:
With .ParagraphFormat
.LineRuleWithin = msoTrue
.SpaceWithin = 1
.LineRuleBefore = msoTrue
.SpaceBefore = 0.25
.LineRuleAfter = msoFalse
.SpaceAfter = 0
End With
.Text = "Heading" & vbCr & "Bullet 1" & vbCr & "Bullet 2" & vbCr & "Bullet 3"
.ParagraphFormat.Alignment = ppAlignLeft
.Paragraphs(1, 1).Font.Size = 14
.Paragraphs(1, 1).Font.Color = myHeader
.Paragraphs(2, 3).Font.Size = 14
.Paragraphs(2, 3).Font.Color = myBody
'turn off bullet for Header
.Paragraphs(Start:=1, Length:=1).ParagraphFormat.Bullet.Visible = msoFalse
'bullet format for next 3 paragraphs
.Paragraphs(Start:=2, Length:=3).ParagraphFormat.Bullet.Visible = msoTrue
.Paragraphs(2).IndentLevel = 1
.Paragraphs(3).IndentLevel = 2
.Paragraphs(4).IndentLevel = 3
With .Paragraphs(Start:=2, Length:=1).ParagraphFormat.Bullet
.Visible = msoTrue
With .Font
.Name = "Wingdings 2"
.Color.RGB = myBullets
End With
.Character = 151
End With
With .Paragraphs(Start:=3, Length:=1).ParagraphFormat.Bullet
.Visible = msoTrue
With .Font
.Name = "Arial"
.Color.RGB = myBullets
End With
.Character = 8211
End With
With .Paragraphs(Start:=4, Length:=1).ParagraphFormat.Bullet
.Visible = msoTrue
With .Font
.Name = "Wingdings"
.Color.RGB = myBullets
End With
.Character = 167
.RelativeSize = 0.9
End With
... and the situation where I want to call this varies depending on how many placeholders I have on the slide. Like, for 2 Columns, I would have:
With ActivePresentation.Slides(mySlide)
Set sObj = ActivePresentation.Slides.Add(mySlide + 1, ppLayoutTwoColumnText).Shapes
With sObj.Placeholders(2).TextFrame.TextRange
Call ___mySpecialRoutine___
end with
I'm guessing the answer is no and I'll have to figure out a way to make it a real subroutine. :dunno