Creazione di elenco puntato nidificato in PowerPoint 2007
-
03-10-2019 - |
Domanda
Stiamo cercando di creare una diapositiva di PowerPoint programmaticaly. Possiamo ottenere proiettili su un unico livello, ma giocare con le schede e ritorno della linea non funziona per le enumerazioni nidificate.
Per ora otteniamo:
- Testo 1
- subtext1
- subtext2
- Testo 2
E quello che vogliamo è:
- Testo 1
- subtext1
- subtext2
- Testo 2
C'è un modo per controllare questi utilizzando C # o VBA?
Soluzione
In primo luogo, ottenere un riferimento al Paragraphs
del TextRange2
, in quanto ogni elemento puntato è un paragrafo (in realtà 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)
Le ultime quattro righe chiamare una funzione che incapsula la logica di impostazione del rientro "livello", che colpisce lo stile dei punti e testo, e l'effettivo rientro dei proiettili e il testo:
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
Si potrebbe certamente refactoring questo per soddisfare le vostre esigenze -. Come passare il fattore trattino (I hardcoded come 40, ma la vostra situazione potrebbe essere diversa)