2016-09-29 1 views
0

저는 VBA에 매우 익숙하며 슬라이드에서 모든 모양을 가져와야하는 ppt 프레젠테이션을 가지고 있습니다. 위치 (왼쪽, 위)와 크기 (너비, 높이)를 연결해야하는 슬라이드도 가져와야합니다. 먼저 어디에서 확인해야합니까?VBA의 위치, 크기 및 href를 얻으십시오.

나는 뭔가를 가지고 있지만, 여전히 개선해야합니다. 그것이 잘 작동하는지 정말로 알지 마라.

Sub Slide() 

Dim sld As Slide 
Dim shp As Shape 
Dim count As Integer 

count = 1 

    For Each sld In ActivePresentation.Slides 
     For Each shp In sld.Shapes 

      Debug.Print count 
      Debug.Print shp.Left 
      Debug.Print shp.Top 
      count = count + 1 

     Next shp 
    Next sld 

최종 하위

+0

은 당신이 지금까지 시도 했습니까? 뭐 확인 했니? – trincot

+0

예, 질문을 업데이트하겠습니다. –

답변

2

중첩 루프, 당신이 언급 한 정보 플러스 각 모양의 ID와 이름을 출력, 활성 프레젠테이션의 모든 슬라이드 및 각 슬라이드의 모든 도형을 반복. 내부 하이퍼 링크가 있으면 연결된 슬라이드에 대한 일부 정보가 출력됩니다. 또한 링크 된 슬라이드의 객체에 대한 참조를 얻기위한 코드를 추가했습니다.

Option Explicit 

Sub OutputSlides() 
    Dim oSlide As Slide 
    Dim oShape As Shape 
    Dim i As Long 
    Dim oAction As ActionSetting 
    Dim oHyperlink As Hyperlink 

    For Each oSlide In ActivePresentation.Slides 
     For Each oShape In oSlide.Shapes 
      Debug.Print "Shape #" & oShape.Id & " (" & oShape.Name & ") - Slide: " & oSlide.SlideNumber & " Position: " & oShape.Left & "," & oShape.Top _ 
       ; " Size: " & oShape.Width & "x" & oShape.Height 


      For Each oAction In oShape.ActionSettings 
       On Error Resume Next 

       If oAction.Action = ppActionHyperlink Then 
        Set oHyperlink = oAction.Hyperlink 

        ''See more: http://www.pptfaq.com/FAQ00162_Hyperlink_-SubAddress_-_How_to_interpret_it.htm 
        Dim parts() As String 
        Dim slideId As Long 
        Dim slideIndex As Long 
        Dim slideTitle As String 
        Dim linkedSlide As Slide 

        parts = Split(oHyperlink.SubAddress, ",") 

        slideId = CLng(parts(0)) 
        slideIndex = CLng(parts(1)) 
        slideTitle = parts(2) 

        If slideId > 0 Then 
         Debug.Print " --Internal hyperlink to slide #: " & slideIndex & "(id: " & slideId&; ", title: " & slideTitle & ")" 

         ''this gets you a reference to the linked slide if you need it: 
         ''Set linkedSlide = oShape.Parent.Parent.Slides(slideIndex) 
        End If 

       End If 
      Next oAction 
     Next oShape 
    Next oSlide 
End Sub 

예 출력 :

이 가 가
Shape #2 (Title 1) - Slide: 1 Position: 120,88,37504 Size: 720x188 
Shape #3 (Subtitle 2) - Slide: 1 Position: 120,283,625 Size: 720x130,375 
Shape #4 (CommandButton1) - Slide: 1 Position: 120,73 Size: 237x141 
Shape #5 (TextBox1) - Slide: 1 Position: 514,1251,134,875 Size: 72x72 
Shape #2 (Title 1) - Slide: 2 Position: 120,88,37504 Size: 720x188 
Shape #3 (Subtitle 2) - Slide: 2 Position: 120,283,625 Size: 720x130,375 
Shape #4 (CommandButton1) - Slide: 2 Position: 120,73 Size: 237x141 
Shape #5 (TextBox1) - Slide: 2 Position: 514,1251,134,875 Size: 72x72 
Shape #2 (Title 1) - Slide: 3 Position: 66,28,75 Size: 828x104,375 
Shape #3 (Content Placeholder 2) - Slide: 3 Position: 66,143,75 Size: 828x342,625 
Shape #5 (Straight Arrow Connector 4) - Slide: 3 Position: 175,4366,201,8028 Size: 263,662x140,9577 
--Internal hyperlink to slide #: 3(id: 257, title: Slide 3) 
+0

하이퍼 링크가있는 경우 하이퍼 링크를 얻을 수있는 방법이 있습니까? –

+0

안녕하세요, 선택한 Shape의 하이퍼 링크 개체 (있는 경우)를 가져 오는 코드를 추가했습니다. 정확하게 어떤 종류의 하이퍼 링크를 고려해야할지 모르겠으므로 링크 된 문서를 살펴보십시오. – Jbjstam

+0

ppt에는 해당 ppt 프레젠테이션의 다른 슬라이드에 링크되는 모양이 있습니다. –