Creación de lista de viñetas anidadas en PowerPoint 2007
-
03-10-2019 - |
Pregunta
Estamos tratando de crear una diapositiva de PowerPoint programmaticaly. Podemos obtener balas en un solo nivel, pero jugar con tabulaciones y retornos de línea no funciona para enumeraciones anidados.
Por ahora obtenemos:
- Texto 1
- subtext1
- subtext2
- Texto 2
Y lo que queremos es:
- 1 texto
- subtext1
- subtext2
- Texto 2
¿Hay una manera de controlar estas usando C # o VBA?
Solución
En primer lugar, obtener una referencia a la Paragraphs
del TextRange2
, ya que cada línea de la lista es un párrafo (realmente un TextRange2
).
Dim pres As Presentation
Set pres = Application.ActivePresentation
Dim slide As slide
Set slide = pres.Slides(2)
Dim shapes As shapes
Set shapes = slide.shapes
Dim textShape As Shape
Set textShape = shapes(2)
Dim textFrame As TextFrame2
Set textFrame = textShape.TextFrame2
Dim textRng As TextRange2
Set textRng = textFrame.textRange
Dim p As TextRange2
Set p = textRng.Paragraphs
SetIndent 1, p.Item(1)
SetIndent 2, p.Item(2)
SetIndent 2, p.Item(3)
SetIndent 1, p.Item(4)
Las últimas cuatro líneas de llamar a una función que encapsula la lógica de establecer el guión "nivel", que afecta al estilo de las viñetas y el texto, y el guión real de las viñetas y el texto:
Private Function SetIndent(ByVal level As Integer, ByRef p As TextRange2)
p.ParagraphFormat.IndentLevel = level
p.ParagraphFormat.FirstLineIndent = 40
p.ParagraphFormat.LeftIndent = level * 40
End Function
Por supuesto que podría refactorizar esto para satisfacer sus necesidades -. Como pasar el factor guión (I hardcoded como 40, pero su experiencia puede variar)