Unable to indent bullets as paragraphs when using VBA in PowerPoin

J

Jimbo1004

I am not able to actually indent bullets as paragraphs when using VBA in
PowerPoint 2007. I am able to select any or all of the paragraphs (bullet
list), but when I try to increase the indentlevel from 1 to 2, the bullet
number changes, but the actual text remains left justified and doesn't move.
If I click on the bullet text and then click on the promote button on the
screen, the text does in fact move to the right as expected. The table that
I built has 2 rows and 2 columns. The cell content are in the second row,
first column. Any ideas? Below is a snippet of my code:

Sub indent()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)

PPPres.Slides(1).Shapes("Table").Table.Cell(2,
1).Shape.TextFrame.TextRange.Paragraphs(3).Select
With PPPres.Slides(1).Shapes("Table").Table.Cell(2,
1).Shape.TextFrame.TextRange
.Paragraphs(3).IndentLevel = 2
End With
End Sub

In the table, I have 5 bullet items like this:

1. aaaaa
2. bbbbb
3. ccccc
4. ddddd
5. eeeee

After running the above routine, I get the following:

1. aaaaa
2. bbbbb
1. ccccc
3. ddddd
4. eeeee

So I know it is properly selecting the paragraph since the 3rd indent bullet
is now at "1" and the other bullets after the 3 bullet are reordered. What I
would expect to see if the indentlevel property was working correctly is the
following in the table cell:

1. aaaaa
2. bbbbb
1. ccccc
3. ddddd
4. eeeee

Suggestions?
 
S

Steve Rindsberg

Jimbo1004 said:
I am not able to actually indent bullets as paragraphs when using VBA in
PowerPoint 2007. I am able to select any or all of the paragraphs (bullet
list), but when I try to increase the indentlevel from 1 to 2, the bullet
number changes, but the actual text remains left justified and doesn't move.

The amount of indent for the various indent levels is governed by the
.FirstLineIndent and .LeftIndent settings of the paragraph.

These used to be properties of the .Ruler object of the TextFrame, but now that
each paragraph can have its own tabs and indents, they're exposed through the
ParagraphFormat object. See mods to your code below:
Sub indent()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)

You don't really need this at all ... unless you specifically WANT to watch PPT
select the object (which slows down your code tremendously)
PPPres.Slides(1).Shapes("Table").Table.Cell(2,
1).Shape.TextFrame.TextRange.Paragraphs(3).Select

And instead of this:
With PPPres.Slides(1).Shapes("Table").Table.Cell(2,
1).Shape.TextFrame.TextRange
.Paragraphs(3).IndentLevel = 2
End With

Do:

With PPPres.Slides(1).Shapes("Table").Table.Cell(2,
1).Shape.TextFrame.TextRange.Paragraphs(3)
with .ParagraphFormat
.FirstLineIndent = 20
.LeftIndent = 10
end with
.IndentLevel = 2
End With
 
J

Jimbo1004

Thanks for your suggestion. I tried your recommendation, but was greeted with
error message indicating that the "Method or Datamember is not found" and the
FirstLineIndent is highlighted as the offending item. The same is true with
the LeftIndent property. When I go into the MSDN reference library for
PowerPoint, the FirstLineIndent an LeftIndent is not listed. However, both
of these are listed as properties of Word. Any other thoughts?
 
S

Steve Rindsberg

Thanks for your suggestion. I tried your recommendation, but was greeted with
error message indicating that the "Method or Datamember is not found" and the
FirstLineIndent is highlighted as the offending item. The same is true with
the LeftIndent property. When I go into the MSDN reference library for
PowerPoint, the FirstLineIndent an LeftIndent is not listed. However, both
of these are listed as properties of Word. Any other thoughts?

Post what you've got now and I'll give it a try here.
 
J

Jimbo1004

I figured out the problem (there are two). The first is that I needed to
format the table cell using the Ruler object in the TextFrame to setup the
indents. The second, and more sinister, is that this only worked for me
AFTER bullets (paragraphs) were put into the cell AND each bullet (paragraph)
was assigned an IndentLevel. Your initial response got me rethinking about
experimenting with Ruler object and trying out different methods. I've
inserted the Ruler object into the original code as a reference. Thanks for
your help

Steve Rindsberg said:
Post what you've got now and I'll give it a try here.

With PPPres.Slides(1).Shapes("Table").Table.Cell(2, 1).Shape.TextFrame.Ruler
.Levels(1).FirstMargin = 0
.Levels(1).LeftMargin = 40
.Levels(2).FirstMargin = 60
.Levels(2).LeftMargin = 100
.Levels(3).FirstMargin = 120
.Levels(3).LeftMargin = 160
.Levels(4).FirstMargin = 180
.Levels(4).LeftMargin = 220
.Levels(5).FirstMargin = 240
.Levels(5).LeftMargin = 280
End With
 
S

Steve Rindsberg

I figured out the problem (there are two). The first is that I needed to
format the table cell using the Ruler object in the TextFrame to setup the
indents. The second, and more sinister, is that this only worked for me
AFTER bullets (paragraphs) were put into the cell AND each bullet (paragraph)
was assigned an IndentLevel.

Yes. Nasty, isn't it? In some cases, you can beat it into behaving rationally by
putting in dummy text, formatting it to taste, then deleting it. The formatting seems
to then "stick" when you add "real" text later.

Your initial response got me rethinking about
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top