使用带有Outlook VBA的PDFMaker插件

loading...


0

我在Outlook 2013中使用Adobe PDFMaker插件 .

我正在使用PDFMOutlook 1.0类型库,它提供了一个PDFMaker类 .

该类提供了CreatePDFFromEntryID和CreatePDF方法 .

CreatePDFFromEntryID将entryID作为参数,一个布尔值指示条目是文件夹还是文件的输出路径 .

此代码将生成传递的文件夹ID的内容的基本PDF:

Sub BasicPDF(sFolderID As String, sFilename As String)
    Dim objPDFMaker As PDFMOUTLOOKLib.PDFMaker
    Dim i As Integer

    'Find PDFMaker addin
    For i = 1 To Application.COMAddIns.Count
        If InStr(UCase(Application.COMAddIns.Item(i).Description), "PDFMAKER") > 0 Then
            Set objPDFMaker = Application.COMAddIns.Item(i).Object
            Exit For
        End If
    Next i

    'If not found, show error message
    If objPDFMaker Is Nothing Then
        MsgBox "Cannot Find PDFMaker add-in", vbOKOnly, ""
        Exit Sub
    End If

    'Create PDF of contents of folder
    objPDFMaker.CreatePDFFromEntryID sFolderID, True, sFilename

    'Tidy up
    Set objPDFMaker = Nothing
End Sub

我想创建一个投资组合PDF .

通过使用CreatePDF方法,PDFMaker可以在资源管理器中创建当前所选项目的增强PDF .

CreatePDF将参数“xmlConfigFile As String”作为参数,但我无法找到XML字符串/文件需要包含的任何文档或示例 .

页面Saving multiple e-mails to pdf with PDFMAKERUse PDFMaker with MS Outlook是我在StackOverflow上找到的最接近的页面,但是这两个页面都试图使用"AdobePDFMakerForOffice"库而不是"PDFMOutlook",并且似乎都没有可用的解决方案 .

有没有人举例说明如何将参数作为XML字符串传递给PDFMaker?

谢谢

loading...

1回答

  • 0

    您可以使用以下代码将参数转换为xml:

    Dim doc As MSXML2.DOMDocument60, pi
        Dim root As IXMLDOMElement, dataNode As IXMLDOMElement
        Dim i As Long
    
        For i = 2 To Sheets(1).UsedRange.Rows.Count
    
            Set doc = New MSXML2.DOMDocument60
    
            Set root = doc.createElement("list")
            doc.appendChild root
    
            Set dataNode = doc.createElement("data")
            root.appendChild dataNode
    
            AddAttributeWithValue dataNode, "name", Range("B" & i)
            AddAttributeWithValue dataNode, "lastname", Range("C" & i)
            AddAttributeWithValue dataNode, "age", Range("E" & i)
    
            Set pi = doc.createProcessingInstruction("xml", "version=""1.0""")
            doc.InsertBefore pi, doc.ChildNodes.Item(0)
    
            doc.Save "C:\_Stuff\xml\" & Range("B" & i).Value & ".xml"
        Next i
    
        MsgBox "Successfully exported Excel data to XML!", vbInformation
    
    End Sub
    

    参考来自:

    Creating each row of excel data into xml files using VBA Macro

评论

暂时没有评论!