Question

I am trying to access the indentation levels of various bulleted list items. So I created a simple function:

private float[] findIndentSpacing(TextRange t, int level) {
    if(level == 1) {
            RulerLevel rl = t.Parent.Ruler.Levels(2);
            //bullet must start at 0 on the first level for now
            return new float[2] { 0, rl.LeftMargin * Settings.Scaler() };
        } else {
            RulerLevel rl = t.Parent.Ruler.Levels[level];
            return new float[2] { rl.FirstMargin * Settings.Scaler(), rl.LeftMargin * Settings.Scaler() };
        }
    }

So that first if statement is a work around. The first level LeftMargin always returns: -2.14748365E+9 for some reason. I've tried to just grab levels after the first and they return actual values. That being said, after one level has been accessed all other levels change and become equal. For example if I try to access: t.Parent.Ruler.Levels[2].FirstMargin, then for some reason t.Parent.Ruler.Levels[3].FirstMargin become the same, and so forth. LeftMargin changes also.

I've tried accessing the ruler object in different ways: by selection, by shape, by text and every way I've thought to try the result is the same.

Ideas?

More info: I read the following threads, but they are more about writing than reading, but I feel like the problem is similar: PowerPoint Programming: Indentation with Ruler margin levels not working? http://answers.microsoft.com/en-us/office/forum/office_2007-customize/why-shapetextframerulerlevelsi-cant-set-the-bullet/9eac3e46-b13b-433e-b588-216ead1d9c1a?tab=AllReplies#tabs I made this one: http://answers.microsoft.com/en-us/office/forum/office_2010-customize/find-bullet-spacing-information-in-an-automated/4525b6b8-6331-4f33-8127-789ea3641589?page=1&tm=1336535132591

Was it helpful?

Solution

In 2007 and 2010 I think you'll need to work with TextRange2 and TextFrame2 objects.

In PPT 2003 and previous, the TextFrame could have 5 indent levels, and all paragraphs at a given indent level shared the same LeftMargin and FirstMargin.

From 2007 on, TextFrames can have up to 9 indent levels, and each paragraph can have its own Left/First margins, independent of the margins set on other paragraphs at the same indent level.

Try this in PPT's VBA IDE. Select the text you're looking at then:

Sub Levels()
  Dim oSh as Shape
  Dim x As Long

  Set oSh = ActiveWindow.Selection.ShapeRange(1)

  With oSh.TextFrame2.Ruler
    For x = 1 to .Count
      Debug.Print .Levels(x).FirstMargin
      Debug.Print .Levels(x).LeftMargin
    Next
  End With

End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top