求助各位高手,我準備將word檔案逐頁列印成pdf,根據頁面大小不同,在生成的pdf檔案名中增加描述加以區分,但運行不是很正確,運行時出現下列錯誤提示,
實時錯誤‘ -2147417851(80010105) ’ :
物件‘ FileToPdf ’的方法‘ IPdfDistiller ’ 失敗
有人能告訴我錯在哪里嗎

For i = List2.ListCount - 1 To 0 Step -1
dPath = sPath & "\" & List2.List(i) '獲得word檔案的完整路徑
If Dir(dPath) <> "" Then myWord.Documents.Open dPath '打開選中的檔案
'myWord.Visible = True
k = 0
'Word檔案的總頁碼
iTotalPage = myWord.Selection.Information(wdNumberOfPagesInDocument)
Set myPdfDistiller = New PdfDistiller
myWord.ActivePrinter = "Adobe PDF"
For j = 1 To iTotalPage
'將檔案逐頁列印成*.ps檔案
myWord.ActiveDocument.PrintOut Background:=True, Append:=False, Range:=wdPrintCurrentPage, _
OutputFileName:=oPath & "\" & Left(List2.List(i), Len(List2.List(i)) - 4) & sPec & "-" & j & ".ps", _
Item:=wdPrintDocumentContent, Copies:=1, PageType:=wdPrintAllPages, PrintToFile:=True, _
Collate:=True, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
'將列印的*.ps檔案轉換成*.pdf檔案
myPdfDistiller.FileToPDF strInputPostScript:=oPath & "\" & Left(List2.List(i), Len(List2.List(i)) - 4) & _
sPec & "-" & j & ".ps", strOutputPDF:=oPath & "\" & Left(List2.List(i), Len(List2.List(i)) - 4) & sPec & _
"-" & j & ".pdf", strJobOptions:=""
Kill oPath & "\" & Left(List2.List(i), Len(List2.List(i)) - 4) & "-" & j & ".ps"
Kill oPath & "\" & Left(List2.List(i), Len(List2.List(i)) - 4) & "-" & j & ".log"
k = k + 1
Text2.Text = "列印狀態,共" & iTotalPage & "頁,正在列印第" & k & "頁!"
myWord.Selection.GoToNext wdGoToPage
Next j
uj5u.com熱心網友回復:
Word什么版本,安裝PDF過濾器了么?uj5u.com熱心網友回復:
word03~10均有這個問題,已經安裝Adobe acrobat professional并參考了adobe distiller,不理解為什么出現這個問題,而且單步除錯是正常的,正常執行時就出現問題了uj5u.com熱心網友回復:
word03~10均有這個問題,已經安裝Adobe acrobat professional并參考了adobe distiller,不理解為什么出現這個問題,而且單步除錯是正常的,正常執行時就出現問題了uj5u.com熱心網友回復:
word03~10均有這個問題,已經安裝Adobe acrobat professional并參考了adobe distiller,不理解為什么出現這個問題,而且單步除錯是正常的,正常執行時就出現問題了uj5u.com熱心網友回復:
1、每行代碼都加個日志,表示執行到哪行。編譯后測驗,看程式到哪行代碼失敗。2、每行代碼加暫停試試。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/121711.html
