PDA

View Full Version : [SLEEPER:] Insert bullets in autoshape using VBA



cyber_amol
02-29-2008, 08:11 AM
I m having tough time inserting bulleted text in autoshape. This is because i dutn know how to apply bullets from VBA or usng macro. Also i want the bullets to appear just like they appear in silde master layout or any other bulleted layout for that matter. how can i do this please help. i m trying to do this for last 3-4 days. :banghead: Nothing.

Andy Pope
02-29-2008, 12:30 PM
Hi,

The macro recorder provided the import bits.


Sub Macro1()
' Macro recorded 29/02/2008 by Andy Pope
Dim vntBulletListText As Variant
Dim vntItem As Variant
vntBulletListText = Array("One", "Two", "Three")
With ActivePresentation.Slides(1)
With .Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 400, 200)
With .TextFrame
.WordWrap = msoTrue
With .TextRange
.Paragraphs(Start:=1, Length:=1).ParagraphFormat.Bullet.Visible = msoTrue
For Each vntItem In vntBulletListText
.Text = vntItem & vbCr
Next
End With
End With
End With
End With
End Sub

cyber_amol
02-29-2008, 10:06 PM
Hey Andy first thank you very much. your code was big help.

However these bullets dunt appear like in Slide master. In slide master, these bullets look really diffrent and they behave lil bit diffrent also these bullets have limitation of 3 lavel, so they dont go beyond 3 lavel. Can you help me how do i achive that.

Thanx for the reply again.

Andy Pope
03-01-2008, 04:08 AM
One thing I missed was the appending of existing text.


.Text = .Text & vntItem & vbCr

You are limited to 5 levels of indenting.

cyber_amol
03-01-2008, 05:58 AM
Hey Andy thanx man... yes it is working well...:clap: :bow:
may call upon u again hope u dunt mind :)

cyber_amol
03-03-2008, 06:51 AM
Hey ,

Having problem...

I can not make muilty level indenting to the bulets i user chr$(13) and char$(9) but gives me wrong respons.

I want them to appear like this:

* Sub 1
- Sub 2
- Sub 3
- Sub 4

Instade they appear like this.

* Sub 1
* Sub 2
* Sub 3
* Sub 4

John Wilson
03-03-2008, 01:03 PM
If you want the bullet styles to follow the master you will need to add the text to a placeholder. If it has to be in an autoshape select, cut and paste it once the bullets are correct. You will probably need to set the ruler levels and vertical anchor too.

cyber_amol
03-05-2008, 05:40 AM
Hey John,

Thanx for the help.
I tried doing that too. but i am not able to add text in the placeholder.


On Error Resume Next
With pptSlide2
With .Shapes.AddPlaceholder(ppPlaceholderBody, 100, 100, 400, 200)
.AlternativeText = "Jadhav"
.TextFrame.TextRange.Text = "Amol"
With .TextFrame
.WordWrap = msoTrue
With .TextRange
.Paragraphs(Start:=1, Length:=1).ParagraphFormat.Bullet.Visible = msoTrue
.Paragraphs(Start:=1, Length:=1).ParagraphFormat.Bullet.Character = 8226
.Text = "Sub 1" & Chr$(13) & Chr$(9)
.Text = .Text & "Sub 2" & Chr$(13) & Chr$(9)
.Text = .Text & "Sub 3" & Chr$(13) & Chr$(9)
.Text = .Text & "Sub 4" & Chr$(13)
End With
End With
End With
End With


Also i am having real problem giving each line a diffrent fornt.

I try to record macro wher i was changing the anchor and rulars, they dunt get recorded in macro.

i want my bullets to appear like this
note:- i am using * for showing the space in following example
First 2 lines are simple text then bullets starts.
=================================
Text 1
Text 2
#**Text3
***#**Text3
******#**Text4
*********#**Text4
=================================
Following is the code that i am using to achive above


pptSlide2.Shapes.AddTextbox(msoTextOrientationHorizontal, pptSlide2.Shapes(selShapeName).Left, (pptSlide2.Shapes(selShapeName).Top + 28.8), pptSlide2.Shapes(selShapeName).Width, (pptSlide2.Shapes(selShapeName).Height - 28.8)).Select
pptTempShape = pPowerPointApp.ActiveWindow.Selection.ShapeRange.Name
With pptSlide2.Shapes(pptTempShape)
.TextFrame.WordWrap = msoTrue
.TextFrame.TextRange.Text = "Text 1" & Chr$(13)
With .TextFrame.TextRange
.Font.Size = 9
.Font.Name = "Arial"
End With
.TextFrame.TextRange.Text = .TextFrame.TextRange.Text & "Text 2" & Chr$(13)
With .TextFrame.TextRange
.Font.Size = 9
.Font.Name = "Times New Roman"
End With
.TextFrame.TextRange.Text = .TextFrame.TextRange.Text & "Sub 1" & Chr$(13) & Chr$(9)
.TextFrame.TextRange.Text = .TextFrame.TextRange.Text & "Sub 2" & Chr$(13) & Chr$(9)
.TextFrame.TextRange.Text = .TextFrame.TextRange.Text & "Sub 3" & Chr$(13) & Chr$(9)
.TextFrame.TextRange.Text = .TextFrame.TextRange.Text & "Sub 4" & Chr$(13)
With .TextFrame.TextRange
.Font.Size = 9
.Font.Name = "Times New Roman"
.Paragraphs(Start:=1, Length:=1).ParagraphFormat.Bullet.Visible = msoTrue
.Paragraphs(Start:=1, Length:=1).ParagraphFormat.Bullet.Character = 8226
End With
End With