簡體   English   中英

無法從 Excel 打開 Powerpoint 演示文稿

[英]Can't open Powerpoint presentation from Excel

我有一個文件在我的運行 Win XP、Excel 2003 的電腦上運行良好。PowerPoint 駐留在 Office 11 中。需要轉到另一台 PC 相同的文件,但 PowerPoint 在 Office 10 中。我的文件“工作”很好,但會無法在所有 PC 上打開 PPT 演示文稿。 所以我需要一種不同的方式來打開它們。 我正在使用 Shell 調用打開,這很好。 我從 Ron DeBruin 那里找到了一個片段,這種片段很有效。 不過,它在公開場合部分失敗了。 這是重要的代碼。 PowerPoint 確實作為應用程序打開,但文件本身不在應用程序中打開。 我收到一個自動化錯誤,並在同一個彈出窗口中出現Unspecified Error Excel 是否有更好的方法來查找 PowerPoint 所在的位置並以這種方式打開它?

    Public Sub Start_Viewer(ProgFile)

      Dim objPPT As Object
      Dim PrgName As String

      Set objPPT = CreateObject("PowerPoint.Application")
      objPPT.Visible = True

      PrgName = Mid(ProgFile, InStrRev(ProgFile, "\") + 1, InStrRev(ProgFile, ".") - InStrRev(ProgFile, "\") - 1)

      objPPT.Presentations.Open FileName:="S:\Lab\EHS\SAFETY\" & PrgName & "\PPT\" & PrgName & ".ppt"
      Workbooks.Open FileName:="S:\Lab\EHS\SAFETY\" & PrgName & "\Quizzes\" & PrgName & " Quiz.xls"

    End Sub

objPPT.Presentations.Open是失敗的部分。 我在打開后添加了FileName,因為我在某處的另一篇文章中看到了它。 不管有沒有那個,它都會失敗。

僅適用於我的 PC 的原始工作代碼。

      Public Sub Start_Viewer(ProgFile)

      '  This works for PowerPoint in this location only and on my work PC
      '  It fails on other pcs at work when PowerPoint resides elsewhere.

      '  ProgFile is the path passed from the calling subroutine _
         and opens the PowwerPoint Presentation for that file
      RetVal = Shell("C:\Program Files\Microsoft Office\Office\PPTView.exe " & Chr(34) & ProgFile & Chr(34), 1)

      Watched = MsgBox("Have you finished the presentation?", vbYesNo, "Verify Presentation Watched")
        Select Case 6
                 ' PrgName is JUST the extracted FileName (no path no extension) to give me folder names
                 PrgName = Mid(ProgFile, InStrRev(ProgFile, "\") + 1, InStrRev(ProgFile, ".") - InStrRev(ProgFile, "\") - 1)
                 Workbooks.Open FileName:="S:\Lab\EHS\SAFETY\" & PrgName & "\Quizzes\" & PrgName & "Quiz.xls"
               Case 7
                 Exit Sub
        End Select
      End Sub

您可能需要檢查EzPaste以自動執行從 Excel 粘貼到 PPT 的過程

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM