如何使用API​​嵌入将Docusign Envelope数据查询到Excel?

时间:2015-02-20 20:46:51

标签: vba excel-vba docusignapi excel

我一直试图找到一种方法,使用docusign通过vba嵌入API将数据导入excel。与其他网站如快速基站一样,这是一个非常简单的过程,我使用vba来调用Internet Explorer,然后从xml响应中提取我需要的所有内容或者能够设置Web查询。但是,我还没有办法避免使用更高级的http请求(或其他语言类型)来执行此操作。

以下是我用来查询quickbase的代码,我希望它也适用于docusign。

 Sub qbImport()
        Dim qbUser As String
        Dim qbPassword As String
        qbUserDefault = "Enter User Name Here"
        qbPasswordDefault = "Enter Password Here"
        qbUserMessage = "What is your Quickbase Log-In?" & Chr(13) & Chr(13) & "**It is an email address"
        qbPasswordMessage = "What is your Quickbase Log-In Password?"
        qbUser = InputBox(qbUserMessage, "Quickbase Log-In Email", qbUserDefault)
        qbPassword = InputBox(qbPasswordMessage, "Quickbase Log-In Password", qbPasswordDefault)

        Application.ScreenUpdating = False

        Dim IE As New InternetExplorer
        IE.Visible = False
        IE.navigate "https:// [quickbase url] /db/main?a=API_Authenticate&username=" & qbUser & "&password=" & qbPassword
        Do While IE.Busy
        Loop
        Dim ticket As String
        Dim passwordError As String
        passwordError = IE.document.getElementsByTagName("errtext")(0).innerText
        If passwordError = "<errtext>Unknown username/password</errtext>" Then
            wrongPassword = MsgBox("The log-in information entered is incorrect. Please re-update the report and enter the correct password", vbOKOnly, "Log-In Error")
            IE.Quit
            End
        Else: End If

        ticket = Mid(IE.document.getElementsByTagName("ticket")(0).innerText, 9, Len(IE.document.getElementsByTagName("ticket")(0).innerText) - 17)
        IE.Quit

        Sheets("data").Select
        Cells.Select
        Selection.QueryTable.Delete
        Selection.ClearContents
        Range("A1").Select
        With ActiveSheet.QueryTables.Add(Connection:= _
            "TEXT;https:// [quickbase url] /db/bg6ihpgr5?act=API_GenResultsTable&ticket=" & ticket & "&apptoken= [app token] 
    &qid=205&options=csv", _
            Destination:=Range("$A$1"))
            .Name = "qbData"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .TextFilePromptOnRefresh = False
            .TextFilePlatform = 437
            .TextFileStartRow = 1
            .TextFileParseType = xlDelimited
            .TextFileTextQualifier = xlTextQualifierDoubleQuote
            .TextFileConsecutiveDelimiter = False
            .TextFileTabDelimiter = True
            .TextFileSemicolonDelimiter = False
            .TextFileCommaDelimiter = True
            .TextFileSpaceDelimiter = False
            .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
            .TextFileTrailingMinusNumbers = True
            .Refresh BackgroundQuery:=False
        End With

End Sub

0 个答案:

没有答案