Powerpoint - только VBA - вставка списка пользовательских маркеров - PullRequest
0 голосов
/ 16 октября 2019

Надеюсь, у тебя все хорошо. Я использую код VBA (только не XML) для вставки настраиваемого списка маркеров в выбранный объект (текстовое поле, фигуру и т. Д.), Например Expected Я пробовал следующий код:

Sub CustomBulletsVBAOnly()

With ActiveWindow.Selection.ShapeRange.textFrame
    With .TextFrame2.TextRange.Paragraphs(1)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 140
    End With
    With .TextFrame2.TextRange.Paragraphs(2)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 141
    End With
    With .TextFrame2.TextRange.Paragraphs(3)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 142
    End With
    With .TextFrame2.TextRange.Paragraphs(4)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 143
    End With
    With .TextFrame2.TextRange.Paragraphs(5)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 144
    End With
    With .TextFrame2.TextRange.Paragraphs(6)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 145
    End With
    With .TextFrame2.TextRange.Paragraphs(7)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 146
    End With
    With .TextFrame2.TextRange.Paragraphs(8)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 147
    End With
    With .TextFrame2.TextRange.Paragraphs(9)
        .ParagraphFormat.bullet.Font.name = "Webdings"
        .ParagraphFormat.bullet.Character = 148
    End With

End With
End Sub

Код в настоящее время не работает. У тебя есть идеи? Благодарю. Naxos

Ответы [ 2 ]

0 голосов
/ 17 октября 2019

После нескольких попыток я нашел код, если он кому-то нужен, пожалуйста, найдите его ниже.

Sub InsertCustomBulletList()
 If ActiveWindow.Selection.Type = ppSelectionText Then
     With ActiveWindow.Selection.TextRange
                With ActiveWindow.Selection.TextRange.Lines(1).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(2).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(3).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(4).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(5).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(6).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(7).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(8).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(9).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(10).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(11).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(12).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
               End With
                 With ActiveWindow.Selection.TextRange.Lines(13).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(14).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(15).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(16).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(17).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(18).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(19).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
                With ActiveWindow.Selection.TextRange.Lines(20).ParagraphFormat.bullet
                    .Visible = msoTrue
                    .UseTextColor = msoTrue
                    .Font.name = "Your font"
                    .Character = 0  'Character in ASCII Dec
                    .Font.Color.RGB = RGB(0, 0, 0)
                End With
    End With
 End If
End Sub
0 голосов
/ 17 октября 2019

Ваш код не нужен. Этот стиль нумерации уже встроен в PowerPoint. Вот код для его применения:

Sub NumberStyle()
  With ActiveWindow.Selection.ShapeRange(1).TextFrame2. _
    TextRange.ParagraphFormat.Bullet
    .Type = msoBulletNumbered
    .Style = msoBulletCircleNumWdBlackPlain
  End With
End Sub

Вот моя статья, объясняющая стили нумерации PowerPoint: Взлом OOXML: стили нумерации PowerPoint

...