【发布时间】:2016-02-13 22:05:19
【问题描述】:
我正在使用可以包含动态行的 Excel 文件。我将它导出为 .pdf 并且效果很好。问题是所有内容都在 .pdf 文件的一个页面上。
是否可以在我的 .pdf 文件的 VBA 中插入分页符?
编辑:这是我的分页代码。似乎无法正常工作
If count > 30 Then ' count is the number of row. Break at every 15 rows
Set ws = Range("A1", "K" & count) 'The range of the document
Dim ii As Integer
ii = 21 ' first page break
While count > 0
If count > 15 Then ' no page break if there is less than 15 rows
ws.Rows(ii).EntireRow.PageBreak = xlPageBreakManual
End If
ii = ii + 15
count = count - 15
Wend
End If
编辑 2: 我没有找到任何方法在 pdf 文件中创建分页符。但是,我仍然解决了我的问题。我只是为 vba 找到一个模块来运行外部进程并等待它们。是ShellAndWait
我将 pdf 文件的每一页都保存为临时文档,并将其路径/名称发送到我创建的 C# 控制台应用程序。我正在使用库 PDFsharp 来处理 pdf 文档,然后将它们合并到 1 个文件中。
希望它可以帮助某人。
【问题讨论】: