我有一个文件在运行Win XP,Excel 2003的PC上正常工作.PowerPoint驻留在Office 11中。需要转到另一台PC相同的文件但PowerPoint是在Office 10中。我有的文件" WORKED& #34;我的很好,但不会在所有PC上打开PPT演示文稿。所以我需要一种不同的方式打开它们。我正在使用Shell调用打开,这很好。我找到了Ron DeBruin的片段,这种片段很有效。但它在开放时部分失败。这是重要的代码。 PowerPoint作为应用程序打开但文件本身无法在应用程序中打开。我收到了自动化错误,并且在同一个弹出窗口未指定的错误中。有没有更好的方法让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 。它有或没有失败。
仅适用于MY 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