2017-08-28 2 views
0

Excel、PowerPoint、WordのOLEオブジェクトを使用していますが、私の目的は文書をPDFに変換することです。処理のために新しい '隠し' PowerPoint/Word/Excelウィンドウをプログラムで開く方法

Class PowerPointExporter 
    Sub Export(path As String, newPath As String) 
     Dim application As New PowerPoint.Application 
     Dim presentation As PowerPoint.Presentation = application.Presentations.Open(path) 
     presentation.SaveAs(newPath, PowerPoint.PpSaveAsFileType.ppSaveAsPDF) 
     presentation.Close() 
     application.Quit() 
    End Sub 
End Class 
Class ExcelExporter 
    Sub Export(path As String, newPath As String) 
     Dim application As New Excel.Application 
     Dim wb As Excel.Workbook = application.Workbooks.Open(path) 
     wb.SaveAs(newPath, Excel.XlFixedFormatType.xlTypePDF) 
     wb.Close() 
     application.Quit() 
    End Sub 
End Class 
Class WordExporter 
    Sub Export(path As String, newPath As String) 
     Dim application As New Word.Application 
     Dim doc As Word.Document = application.Documents.Open(path) 
     doc.SaveAs2(newPath, Word.WdSaveFormat.wdFormatPDF) 
     doc.Close() 
     application.Quit() 
    End Sub 
End Class 

だから私の質問は、私はこれらがサイレント作ることができるか、である:

現在、私は非サイレント方法以下がありますか? I.ウィンドウを非表示にする/ウィンドウを画面外に移動する、または同様の方法で移動しますか? PowerPointの

答えて

2

Set PPTObj = New PowerPoint.Application 
    If Debugging Then 
    Set PPTClinic = PPTObj.Presentations.Open(fileName:=PPTFileName, ReadOnly:=msoCTrue, WithWindow:=msoTrue) 'this will prevent the window from being visible 
    Else 
    Set PPTClinic = PPTObj.Presentations.Open(fileName:=PPTFileName, ReadOnly:=msoCTrue, WithWindow:=msoFalse) 'this will prevent the window from being visible 
    End If 

は終わりWithWindowパラメータに注意してください。 Excelの

Set XLobj = New Excel.Application 
    If Debugging Then 
    XLobj.Visible = True 
    Else 
    XLobj.Visible = False 
    End If 

私は長年のかなりの数のWordには何も行っていないが、それはおそらく似たようなのです。

Application.Visible = False 

申し訳ありませんが、気の利いた例は手早くません - 私は私の既存のコード、最後の1から最初の2を取った:私はそれが言葉のためにされて

ああ、here ... Googleは言っていることがわかりますリンクされたページからちょうど借りた。

関連する問題