- Posts: 18
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Excel VBA exporting results with token attributes
3 months 3 weeks ago #236381
by AritzP
Excel VBA exporting results with token attributes was created by AritzP
Hi everyone,
I’m trying to replicate the manual export results with the token attributes with vba in excel:
But i can not find a way to do it with the 'export_responses' function with the remote_handler ( url api ).
This is an example of the manual exportation:
So, is there a way to do it?
Thanks for your attention.
LimeSurvey version: 3.25.15+210223
I’m trying to replicate the manual export results with the token attributes with vba in excel:
Code:
Dim Key As String Dim limeuser As String, limepass As String, limeurl As String, URL As String Dim JsonText As String, jsonObject As Object Dim SurveyID As String, DocumentType As String, LanguageCode As String, CompletionStatus As String, HeadingType As String, ResponseType As String, FromResponse As String, ToResponse As String Dim export64 As String, export64Decoded As String limeurl = "/index.php/admin/remotecontrol" limeuser = "user" limepass = "password" SurveyID = Application.InputBox("Introduzca el ID de la encuesta que quiera importar", "ID Encuesta") DocumentType = "csv" LanguageCode = "" CompletionStatus = "complete" HeadingType = "code" ResponseType = "long" FromResponse = "" ToResponse = "" 'Clear page Cells.Clear 'Initalization Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1") URL = limeurl objHTTP.Open "POST", URL, False objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" objHTTP.setRequestHeader "Content-type", "application/json; charset=utf-8" 'Get key sendtext = "{""method"":""get_session_key"",""params"": [""" + limeuser + """,""" + limepass + """],""id"": 1}" objHTTP.Send (sendtext) JsonText = objHTTP.responseText Set jsonObject = JsonConverter.ParseJson(JsonText) Key = jsonObject("result") 'Export answers sendtext = "{""method"":""export_responses"",""params"": [""" + Key + """,""" + SurveyID + """,""" + DocumentType + """,""" _ + LanguageCode + """,""" + CompletionStatus + """,""" + HeadingType + """,""" + ResponseType + """,""" _ + FromResponse + """,""" + ToResponse + """],""id"": 1}" objHTTP.Send (sendtext) JsonText = objHTTP.responseText Set jsonObject = JsonConverter.ParseJson(JsonText) export64 = jsonObject("result") 'Decode answers export64Decoded = Decode64(export64) 'Close session sendtext = "{""method"":""release_session_key"",""params"": [""" + Key + """],""id"": 1}" objHTTP.Send (sendtext) 'Divide the respond in multiple lines, otherwise evrything is in one cell s = export64Decoded i = 0 While Split(s, Chr(13) + Chr(10))(i) <> "" Cells(i + 1, 1) = Split(s, Chr(13) + Chr(10))(i) i = i + 1 Wend With Application .DecimalSeparator = "." .ThousandsSeparator = "," .UseSystemSeparators = False End With 'Convert CSV Sheets("Data").Columns("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _ Semicolon:=True, Comma:=False, Space:=False, Other:=False, TrailingMinusNumbers:=True Cells.WrapText = False
But i can not find a way to do it with the 'export_responses' function with the remote_handler ( url api ).
This is an example of the manual exportation:
So, is there a way to do it?
Thanks for your attention.
LimeSurvey version: 3.25.15+210223
Please Log in to join the conversation.
- DenisChenu
-
- Away
- LimeSurvey Community Team
-
Less
More
- Posts: 12902
- Thank you received: 2371
3 months 2 weeks ago #237789
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Excel VBA exporting results with token attributes
Looking at code : now way to export at same time
github.com/LimeSurvey/LimeSurvey/blob/87...rol_handle.php#L3149
2 solutions
Export in 2 step, :
1. export response
2. chreck token, export token
3. Redo your array
Create your own export_responses_withtoken in a plugin
Sample here : gitlab.com/SondagesPro/RemoteControl
2 solutions
Export in 2 step, :
1. export response
2. chreck token, export token
3. Redo your array
Create your own export_responses_withtoken in a plugin
Sample here : gitlab.com/SondagesPro/RemoteControl
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Please Log in to join the conversation.