【问题标题】:Merging PDF with pdfforge.dll in VBA on Windows x64在 Windows x64 上的 VBA 中将 PDF 与 pdfforge.dll 合并
【发布时间】:2014-08-23 11:27:09
【问题描述】:

所以我正在处理一个应该合并一些 pdf 的宏。该代码非常简单,使用 PDFCreator setup (pdfforge.dll) 提供的 dll 运行良好,但仅适用于 Windows 32Bits(XP 或 7)。

这里是代码

Dim Pdf As Object
Set Pdf = CreateObject("pdfforge.pdf.pdf")

Pdf.MergePDFFiles_2 FR1, Target & "FusionFR1.pdf", True
Pdf.MergePDFFiles_2 FR2, Target & "FusionFR2.pdf", True
Pdf.MergePDFFiles_2 FR3, Target & "FusionFR3.pdf", True
Pdf.MergePDFFiles_2 FR4, Target & "FusionFR4.pdf", True

请注意,FR1、FR2、FR3 和 FR4 只是一些字符串数组,其中包含我要合并的那些 pdf 的路径。

正如我所说,只要 PDFCreator 的版本提供 pdfforge.dll,此代码在任何具有 Windows 32 位的计算机上都可以正常工作。但是在 Windows 64 位上,我有一个“Excel 自动化错误” 设置 Pdf = CreateObject("pdfforge.pdf.pdf")

我猜这是一个仅在 32 位系统上工作的 dll,默认情况下,Windows 64 位尝试在 64 位环境中工作。所以我尝试通过两种方法为 32 位环境注册这个 dll 却没有得到满意的结果:

希望你们能帮助我:)

PS:我正在使用 Excel 2007

【问题讨论】:

    标签: windows excel pdf-generation excel-2007 vba


    【解决方案1】:

    好吧,我成功了!

    我主要使用Assembly Registration Tool,regasm.exe

    首先,我使用带有 /u 参数的 regasm.exe 确保该 dll 没有在任何地方注册,也就是说在 32 位和 64 位框架中。

    然后我在 framework\v2.0.50727 使用 /codebase 参数注册了 dll (我从多个来源读到这个参数是关键)

    最后,我在 excel 目录的根目录中创建了一个名为 excel.exe.config 的文本文件,其中包含

    <?xml version="1.0"?>
    <configuration>
      <startup>
        <supportedRuntime version="v2.0.50727"/>
      </startup>
    </configuration>
    

    这应该会强制 excel 使用框架 v2。

    希望有一天这可以帮助某人;)

    【讨论】:

      猜你喜欢
      • 2011-07-17
      • 1970-01-01
      • 2021-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多