2017-05-04 10 views
1

ゴール:現在のExcel VBAがオブジェクトとして添付されているPowerPointプレゼンテーションのパスとファイル名を取得します。Excelがオブジェクトとして添付されているPowerPointプレゼンテーションのファイル名とパスを取得します。

以下のスクリーンショットは、より良い私が何を意味するか説明するかもしれない:

enter image description here

これは、私はいくつかのプレゼンテーションを同時に開いている場合、必要なプレゼンテーションを見つける必要があるために使用されるコードです

Option Explicit 

Sub UpdatePowerPoint(PowerPointFile) 

Dim ppProgram       As Object 
Dim ppPres        As Object 
Dim CurOpenPresentation     As Object 

On Error Resume Next 
Set ppProgram = GetObject(, "PowerPoint.Application") 
On Error GoTo 0 

If ppProgram Is Nothing Then 
    Set ppProgram = CreateObject("PowerPoint.Application") 
Else 
    If ppProgram.Presentations.Count > 0 Then 
     For Each CurOpenPresentation In ppProgram.Presentations ' loop through all open presnetations (check Full Name: Path and name) 

      Dim CleanFullName As String * 1024 
      CleanFullName = Replace(CurOpenPresentation.FullName, "%20", " ") ' replace Sharepoint characters %20 with Space ("_") 

      If StrComp(PowerPointFile, CleanFullName, vbTextCompare) = 0 Then 
       Set ppPres = CurOpenPresentation 
       Exit For 
      End If 
     Next CurOpenPresentation 
    End If 
End If 

End Sub 

質問::私は行方不明です - (と私はPresntation名を渡す必要はありませんが、私は、私はに位置していた中でのプレゼンテーションを取得することができ、これまでにないんだけど) n Excel/Office "Trick":Excelファイルを何らかの形でプレゼンテーションと結びつける "トリック"ですか?たぶんいくつかの他の解決策?

+0

"勇敢" downvoterは、理由を説明できますか? –

+1

私は理解していますが、このActivePresentation.Slides(1).Shapes(3).OLEFormat.Object.application.activeworkbook.name'のようなものは、呼び出されているワークブックに対してこれをチェックしています。 2つのヘッダーでスライドし、3番目がデータなので、スライド上でこれらのタイプのオブジェクトを確認する必要があります) –

+0

明確にするために、Powerpointプレゼンテーションファイルの名前とパスへの参照をプレゼンテーション内に埋め込まれたExcelワークブック内のVBAコード? PowerpointのVBAコードに、プレゼンテーションからExcel VBAコードへのファイル名とパスの参照を渡す必要はありませんか? – SteveES

答えて

1

これらの線に沿って何か

Sub T() 

Dim ppProgram As PowerPoint.Application 
Dim ppPresentation As PowerPoint.Presentation 
Dim ppSlide As PowerPoint.Slide 
Dim ppShape As PowerPoint.Shape 
Dim objExcel As Excel.Application 

Set ppProgram = GetObject(, "PowerPoint.Application") 

For Each ppPresentation In ppProgram.Presentations 
    For Each ppSlide In ppPresentation.Slides 
     For Each ppShape In ppSlide.Shapes 
      If ppShape.Type = msoEmbeddedOLEObject Then 
       Set objExcel = ppShape.OLEFormat.Object.Application 
       if objExcel.ActiveWorkbook.Name=activeworkbook.name then stop 
      Else 
      End If 
     Next ppShape 
    Next ppSlide 
Next ppPresentation 

End Sub 
+0

ありがとう、私はそれを打ち、あなたにフィードバックを与えます –

+0

おかげで、 ) –

関連する問題