2010-06-23 4 views
2

PowerPoint에 Excel 및 Word와 같은 API가 있다는 것을 알고 있습니다. 어쨌든 타임 라인 로드맵을 프로그램 방식으로 생성합니까 (데이터베이스에서 마일스톤과 날짜 목록이 있습니다)?C#에서 PowerPoint 로드맵 타임 라인을 생성 할 수 있습니까?

사람이 프로그래밍 방식

파워 포인트

에서 타임 라인 로드맵 템플릿을 작성하려고에 시작하는 방법에 대한 링크 나 예제 코드가 있습니까 여기에 내가 뭘하려고 오전의 (큰되지 않음) 예입니다 http://www.jumpdesign.net/aboutcd/02history/Short_history_timeline.jpg

+0

차트를 의미합니까? –

+0

@Otaku - 여기 예가 있습니다 : http://www.jumpdesign.net/aboutcd/02history/Short_history_timeline.jpg – leora

+0

예, 이와 같은 것은 완전히 수행 할 수 있습니다. 먼저 해독을했는지 확인하기 위해 먼저 검색해 보겠습니다. 그렇지 않은 경우 VBA에서 코드를 작성해 드리겠습니다. 그것을 만드는 재미처럼 보입니다. :) –

답변

2

그래, 아직 작업이 많이 필요하지만 잘하면 시작하기에 충분합니다.

Sub GenerateTimeLine() 
    Dim ap As Presentation 
    Set ap = ActivePresentation 

    'Set to first slide 
    Dim sl As Slide 
    Set sl = ap.Slides(1) 

    'Use Slide Master for Presentation dimensions 
    Dim sm As Master 
    Set sm = ap.SlideMaster 

    'Create a timeline body of 75% the width of the slide 
    Dim w As Integer 
    w = sm.Width * 0.75 

    'Create a timeline body of 5% the height of the slide 
    Dim h As Integer 
    h = sm.Height * 0.1 

    'Center horizontal position of timeline body 
    Dim posX As Integer 
    posX = Abs(w - sm.Width)/2 

    'Center vertical position of timeline body 
    Dim posY As Integer 
    posY = Abs(h - sm.Height)/2 

    'Add main shape 
    Dim timeLineBodyShape As Shape 
    Set timeLineBodyShape = sl.Shapes.AddShape(msoShapeRectangle, posX, posY, w, h) 

    'Set up initial variables 
    Dim timeLineBodyName As String 
    timeLineBodyName = "Showjumping" 
    Dim yearMin As Integer 
    Dim yearMax As Integer 
    yearMin = 1864 
    yearMax = 2006 

    'Add to variables timeline 
    With timeLineBodyShape.TextFrame 
     With .Ruler.TabStops 
      .Add ppTabStopLeft, 0 
      .Add ppTabStopCenter, timeLineBodyShape.Width/2 
      .Add ppTabStopRight, timeLineBodyShape.Width 
     End With 
     With .TextRange 
      .InsertAfter CStr(yearMin) + Chr(9) + timeLineBodyName + Chr(9) + CStr(yearMax) 
      .Font.Bold = msoTrue 
     End With 
    End With 

    'Create time line nodes 
    Dim timeLineNodeYear As Integer 
    Dim timeLineNodeText As String 
    Dim timeLineNodeTop As Boolean 

    timeLineNodeYear = 1864 
    timeLineNodeText = "First Competition. Horse Show of the Royal Dublin Society" 
    timeLineNodeTop = True 
    AddtimeLineNode timeLineBodyShape, timeLineNodeYear, timeLineNodeText, timeLineNodeTop, _ 
     sl, yearMin, yearMax, sm 

    timeLineNodeYear = 1912 
    timeLineNodeText = "Stockholm Olympic Games. Team competition for first time in jumping" 
    timeLineNodeTop = False 
    AddtimeLineNode timeLineBodyShape, timeLineNodeYear, timeLineNodeText, timeLineNodeTop, _ 
     sl, yearMin, yearMax, sm 

    timeLineNodeYear = 1925 
    timeLineNodeText = "Aachen. For the first time Aachen Grand Prix" 
    timeLineNodeTop = True 
    AddtimeLineNode timeLineBodyShape, timeLineNodeYear, timeLineNodeText, timeLineNodeTop, _ 
     sl, yearMin, yearMax, sm 

    timeLineNodeYear = 1953 
    timeLineNodeText = "Paris. For first time World Championship for men" 
    timeLineNodeTop = False 
    AddtimeLineNode timeLineBodyShape, timeLineNodeYear, timeLineNodeText, timeLineNodeTop, _ 
     sl, yearMin, yearMax, sm 

    timeLineNodeYear = 1979 
    timeLineNodeText = "The first Volvo World Cup Final" 
    timeLineNodeTop = True 
    AddtimeLineNode timeLineBodyShape, timeLineNodeYear, timeLineNodeText, timeLineNodeTop, _ 
     sl, yearMin, yearMax, sm 

    timeLineNodeYear = 1990 
    timeLineNodeText = "Stockholm. The first World Equestrian Games" 
    timeLineNodeTop = False 
    AddtimeLineNode timeLineBodyShape, timeLineNodeYear, timeLineNodeText, timeLineNodeTop, _ 
     sl, yearMin, yearMax, sm 

    timeLineNodeYear = 2006 
    timeLineNodeText = "Aachen. Biggest World Equestrian Games until now" 
    timeLineNodeTop = True 
    AddtimeLineNode timeLineBodyShape, timeLineNodeYear, timeLineNodeText, timeLineNodeTop, _ 
     sl, yearMin, yearMax, sm 

End Sub 
Sub AddtimeLineNode(tlShape As Shape, tlYear As Integer, tlText As String, tlTop As Boolean, _ 
     sl As Slide, yearMin As Integer, yearMax As Integer, sm As Master) 

    'Positioning calculations 
    Dim shapeDifference As Single 
    shapeDifference = tlShape.Width - tlShape.Left 

    Dim yearDifference 
    yearDifference = yearMax - yearMin 

    Dim timeLineNodeShape As Shape 

    timeLineNodeShapeWidth = 100 
    timeLineNodeShapeHeight = 100 

    timeLineNodeShapePosLeft = (tlShape.Left + (((tlYear - yearMin)/yearDifference) * shapeDifference)) 
    timeLineNodeShapePosTop = 30 

    If tlTop Then 
     Set timeLineNodeShape = sl.Shapes.AddShape(msoShapeRectangularCallout, timeLineNodeShapePosLeft, _ 
      timeLineNodeShapePosTop, timeLineNodeShapeWidth, timeLineNodeShapeHeight) 
     timeLineNodeShapeMid = timeLineNodeShape.Top + timeLineNodeShape.Height/2 
     timeLineBodyShapeHeight = tlShape.Height 
     Distance = tlShape.Top - timeLineNodeShapeMid 
     handleYplacement = Distance/timeLineNodeShape.Height 
     timeLineNodeShape.Adjustments(2) = handleYplacement 
    Else 
     timeLineNodeShapePosBottom = sm.Height - timeLineNodeShapeHeight - timeLineNodeShapePosTop 
     Set timeLineNodeShape = sl.Shapes.AddShape(msoShapeRectangularCallout, timeLineNodeShapePosLeft, _ 
      timeLineNodeShapePosBottom, timeLineNodeShapeWidth, timeLineNodeShapeHeight) 
     timeLineNodeShapeMid = timeLineNodeShape.Top + timeLineNodeShape.Height/2 
     timeLineBodyShapeHeight = tlShape.Height 
     Distance = (tlShape.Top + tlShape.Height) - timeLineNodeShapeMid 
     handleYplacement = Distance/timeLineNodeShape.Height 
     timeLineNodeShape.Adjustments(2) = handleYplacement 
    End If 

    timeLineNodeShape.TextFrame.TextRange = CStr(tlYear) & ", " & tlText 
    timeLineNodeShape.TextFrame2.AutoSize = msoAutoSizeTextToFitShape 
End Sub 
+0

이것은 아주 좋은 시작입니다. 추가하고 싶은 몇 가지 사항이 있으므로 제안 사항이 있으면 좋을 것입니다. 나는 더 나은 "템플릿"을 발견하고 링크를 추가하고 설명 할 것입니다. – leora

+0

@ooo - 당신이 가지고 있다면 다른 예제를보고 싶습니다. 이것에 추가 할 수있는 것들이 분명히 있습니다 - 또한 조정 핸들의 위치에 대해 좀 더 많은 작업이 필요합니다. –