2010-05-19 7 views
1

우리는 프로그래밍 방식으로 PowerPoint 슬라이드를 만들려고합니다. 단일 레벨에서 글 머리 기호를 얻을 수 있지만 중첩 된 열거 형에서는 탭 및 줄 바꿈으로 재생하는 기능이 작동하지 않습니다. 지금은PowerPoint 2007에서 중첩 된 글 머리 기호 목록 만들기

우리가 얻을 :

  • 텍스트 1
  •         subtext1
  •         subtext2
  • 텍스트 2

차 우리가 원하는 것은 :

  • 텍스트 1
    • subtext1
    • subtext2
  • 텍스트 2

이 사용하는 C# 또는 VBA를 제어 할 수있는 방법이 있습니까?

답변

3

먼저 각 글 머리 기호 항목은 단락 (실제로는 TextRange2)이므로 의 Paragraphs에 대한 참조를 가져옵니다.

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 
:

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) 

마지막 네 줄은 글 머리 기호 및 텍스트의 스타일에 영향을 미치는 "수준"들여 쓰기를 설정하는 로직을 캡슐화하는 기능과 총알의 실제 들여 쓰기 및 텍스트를 호출

들여 쓰기 요소를 전달하는 것과 같이 필요에 맞게 리팩토링 할 수는 있습니다 (단, 40으로 하드 코딩했지만 마일리지가 다를 수 있음).

+0

감사합니다. 작동합니다. –

관련 문제