VBA传真使用服务器上的传真服务器从网络上的计算机

时间:2016-09-21 04:28:12

标签: vba fax

我正在运行Windows Server 2008 R2。我在服务器上安装了传真服务器角色。通过打印文档并在MYSERVER"上选择"传真,我可以使用连接到网络的计算机连接到服务器的外部传真调制解调器传真文件。我能够使用以下代码(我从mdsn.microsoft.com获得)传真.pdf,即使使用管理员帐户登录计算机,也无法从任何其他计算机传真。

Sub fax_report(location_fax_number, report_name, fax_location, fax_file_path)
    Dim objFaxDocument As New FAXCOMEXLib.FaxDocument
    Dim objFaxServer As New FAXCOMEXLib.FaxServer
    Dim JobID As Object

    On Error GoTo Err_Clear

Err_Clear:
    If Err <> 0 Then
        Err.Clear
        Resume Next
    End If

    'Connect to the fax server
    objFaxServer.Connect ("\\MYSERVER")

    'Set the fax body
    objFaxDocument.Body = fax_file_path

    'Name the document
    objFaxDocument.DocumentName = report_name

    objFaxDocument.Recipients.add (location_fax_number)

    JobID = objFaxDocument.ConnectedSubmit(objFaxServer)

    objFaxServer.Disconnect

End Sub

我得到的错误是:

  • 说明:&#34;操作失败&#34;
  • HelpContext:1000440
  • HelpFile:&#34; C:\ Program Files(x86)\ Common Files \ Microsoft 共享\ VBA \ VBA7.1 \ 1033 \ VbLR6.chm&#34;
  • LastDllError:0
  • 编号:-2147023741
  • 资料来源:&#34; FaxComEx.FaxDocument.1&#34;

虽然当我从网络上的计算机上尝试时,我能够从服务器传真.pdf,但它失败了。我能够从网络上的计算机发送.txt文件。看起来.pdf不会像我在服务器上运行代码那样自动转换为.tiff文件。当我从服务器运行代码时,Adobe Acrobat Reader DC打开,打开并转换.pdf然后传真,没有错误。 Adobe保持打开状态,我可以看到创建了临时文件,无法从最近的文件列表菜单中打开它。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。我需要将Adobe Acrobat Reader DC设置为在远程计算机上处​​理.pdfs的默认程序。