Question

I have very limited experience with VBA and excel.

So I have a server which generates reports in .xlsx format for users to download. I'm trying to have an excel macro grab the data from the generated report and insert it into the report automatically without the need for manual copying and pasting.

I have a successful connection to the server and I get the .xlsx file in the form of a string as seen in my code

' Grab file
Dim objHTTP As New WinHttpRequest
objHTTP.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = CInt("&H3300")
objHTTP.Option(WinHttpRequestOption_EnableRedirects) = False
' URL_Report is the server address
objHTTP.Open "GET", URL_Report, False 
objHTTP.setRequestHeader "Accept", "text/html"

' Send HTTP request
objHTTP.send

' This has the .xlsx file in the form of a string
objHTTP.responseText

I want to know the best way to turn the objHTTP.responseText into something usable where I can access the cell values and such OR if that's not possible a good way to send the excel data through my server so that it can be read and used with VBA

Was it helpful?

Solution

You could change the server to export the data in plain text, for exapmle a csv format.

Then, on the otherside, just download the text file and parse it in VBA.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top