2016-07-17 41 views
0

コードの目的:PowerPointが開いていて、検索されたプレゼンテーションが開いている場合は、更新します。プレゼンテーションが閉じている場合は、それを開きます。 PowerPointが閉じられている場合は、新しいインスタンスを作成します。PowerPointプレゼンテーションを開くときにExcel VBAエラー467

エラー

ファイル名を指定して実行時エラー467:リモートサーバーマシン複数のユーザーがユーザーの一人は、次のエラーメッセージを取得し、今日、過去2週間mulitpleコンピュータ上でそれを実行した後、存在しない、または利用できない

ラインコードデバッグモードにhighlightnedありません。

モジュールのコードの

関連セクション:

Public Sub UpdatePowerPoint(PowerPointFile) 

Dim ppProgram       As PowerPoint.Application 
Dim ppPres        As PowerPoint.Presentation 
Dim ppFullPath       As String 
Dim ppName        As String 
Dim activeSlide       As PowerPoint.Slide 

Dim cht         As Excel.ChartObject 
Dim myShape        As Object 
Dim myChart        As Object 
Dim SlideNum, GPLRank     As Integer 
Dim ShapeNum       As Integer 
Dim shapeStageStat      As Shape 

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

ppFullPath = PowerPointFile 
PPT_Export_Success = True 

' check if PowerPoint instance is open 
If ppProgram Is Nothing Then 
    Set ppProgram = New PowerPoint.Application 
    i = 1 
Else 
    If ppProgram.Presentations.count > 0 Then 
     ppName = Mid(ppFullPath, InStrRev(ppFullPath, "\") + 1, Len(ppFullPath)) 
     i = 1 
     ppCount = ppProgram.Presentations.count 
     Do Until i = ppCount + 1 
      If ppProgram.Presentations.Item(i).Name = ppName Then 
       Set ppPres = ppProgram.Presentations.Item(i) 
       GoTo OnePager_Pres_Found 
      Else 
       i = i + 1 
      End If 
     Loop 
    End If 
End If 

ppProgram.Presentations.Open Filename:=PowerPointFile 

' *** Getting the ERROR at the line below *** 
Set ppPres = ppProgram.Presentations.Item(i) 

OnePager_Pres_Found: 
ppPres.Windows(1).Activate ' activate the One-Pager Presentation in case you have several open, and the One_pager is currently not the app "on-focus" 

' --- Added Class script to allow PowerPoint ScreenUpdating set to FALSE --- 
Dim myClass_PPT       As Class_PPT 

Set myClass_PPT = New Class_PPT 
myClass_PPT.ScreenUpdating = False 

' loop through all PowerPoint Slides, and copy all Chart objects from Excel 
For ProjectCounter = 0 To NumberofProjectShts 
    ' copying charts, shapes and other objects 

Next ' ProjectCounter = 0 To NumberofProjectShts 

AppActivate ("Microsoft PowerPoint") 
Set activeSlide = Nothing 
Set ppPres = Nothing 
Set ppProgram = Nothing 

End Sub 
+0

私は何も得ていません。 Power Pointの新しいインスタンスでファイルを開こうとするとエラーが出ますが、 'ppProgram.Visible = msoTrue'はそれを修正しました。私はエラーの原因となるものは見当たりません。エラーを再現できましたか? –

+0

@ThomasInzinaいいえ、私はそれを私のPC上で100回以上実行しましたが、何も、onyl 1ユーザーはそれを持っていませんでした。私はこのエラーメッセージを見て周りを書くかどうか疑問に思っていましたか? –

+0

それはおそらくもう少し時間がかかる場合。問題は、サーバーがVBAの外部に存在することです。私はワークシートにOLEObjectsを追加して参照するのと同様のものに遭遇しました。 OLEObjectsサーバーは、マクロが完了した後にオブジェクトを解放しません。私は、マクロが完了した後、次のプロシージャをミリ秒で呼び出すためにApplication.OnTimeを使用しなければなりませんでした。 –

答えて

0

あなたのコード - 以下の抽出 - 私には少し奇妙に見える:

' check if PowerPoint instance is open 
If ppProgram Is Nothing Then 
    Set ppProgram = New PowerPoint.Application 
    i = 1 
Else 
    If ppProgram.Presentations.count > 0 Then 
     ppName = Mid(ppFullPath, InStrRev(ppFullPath, "\") + 1, Len(ppFullPath)) 
     i = 1 
     ppCount = ppProgram.Presentations.count 
     Do Until i = ppCount + 1 
      If ppProgram.Presentations.Item(i).Name = ppName Then 
       Set ppPres = ppProgram.Presentations.Item(i) 
       GoTo OnePager_Pres_Found 
      Else 
       i = i + 1 
      End If 
     Loop 
    End If 
End If 

ppProgram.Presentations.Open Filename:=PowerPointFile 

' *** Getting the ERROR at the line below *** 
Set ppPres = ppProgram.Presentations.Item(i) 

OnePager_Pres_Found: 
ppPres.Windows(1).Activate ' activate the One-Pager Presentation in case you have several open, and the One_pager is currently not the app "on-focus" 

PowerPointは、いくつかのプレゼンテーションで開かれている場合が、あなたが欲しいものではない(PowerPointFile)、 あなたにエラーを与える行に、あなたは何をしようとしていますか? (私はPresentations.countに等しい)

私は間違っていると思うし、前にライン上で開いたActivePresentationに置き換えてください。

多分、構造/ケース処理がより明確になるようにコードを少し再構成することができます。

関連する問題