通过VBA将Crystal报表导出为pdf

时间:2019-05-15 18:44:25

标签: excel vba internet-explorer crystal-reports

我正在尝试在Internet Explorer中运行报告并以PDF下载。我可以生成报告,但是生成的报告正在我不知道的Crystal Viewer中打开。

我想通过VBA导出报告。

我已经在VBAexpress中发布了一个主题,但是没有得到答复。

Sub Trail1()
    Dim ie As Object
    Dim URL As String
    Dim PropertyNames As String
    Dim TStatus As String
    Dim FrmDate As String
    Dim ToDate As String
    Dim AsOf As String
    Dim Vendor As String
    Dim LockBox As String
    Dim Parse As String
    Dim Destination As String

    PropertyNames = ThisWorkbook.Sheets(2).Range("C14").Value
    TStatus = ThisWorkbook.Sheets(2).Range("C15").Value
    FrmDate = ThisWorkbook.Sheets(2).Range("C16").Value
    ToDate = ThisWorkbook.Sheets(2).Range("C17").Value
    AsOf = ThisWorkbook.Sheets(2).Range("C18").Value
    Vendor = ThisWorkbook.Sheets(2).Range("C19").Value
    LockBox = ThisWorkbook.Sheets(2).Range("C20").Value
    Parse = ThisWorkbook.Sheets(2).Range("C21").Value
    Destination = ThisWorkbook.Sheets(2).Range("C22").Value

    Set ie = CreateObject("Internetexplorer.application")
    ie.Visible = True

    ie.navigate "https://www.yardipcu.com/22466colonysso/pages/SysSqlScript.aspx?Action=FILTER&From=SQLREPORTS&select=reports/rs_jdr_tenant_statement_cobalt.txt"
    Do While ie.readyState <> 4 Or ie.Busy: DoEvents: Loop

    ie.document.getElementsByClassName("form_button")(0).Click

    ie.document.getElementsByName("phMy")(0).Value = PropertyNames
    ie.document.getElementsByName("Status")(0).Value = TStatus
    ie.document.getElementsByName("begmonth")(0).Value = Format(FrmDate, "MM/YYYY")
    ie.document.getElementsByName("endmonth")(0).Value = Format(ToDate, "MM/YYYY")
    ie.document.getElementsByName("begdate")(0).Value = Format(AsOf, "MM/DD/YYYY")
    ie.document.getElementsByName("vendor")(0).Value = Vendor
    ie.document.getElementsByName("lockbox")(0).Value = LockBox
    ie.document.getElementsByName("sParse")(0).Value = Parse
    ie.document.getElementsByName("RptOutput")(0).Value = Destination

    ie.document.getElementsByClassName("filter_submit")(0).Click

    'After this, the report will be generated in a new Crystal Report window
    'I am not even able to get the source code from Inspect Element to proceed with the export

End Sub

0 个答案:

没有答案