Seba Robles
Board Regular
- Joined
- May 16, 2018
- Messages
- 73
- Office Version
- 2019
- 2016
- Platform
- Windows
Hello, so I have a code to download a google sheet as excel to my computer.
I'm getting the following error in my code and can't figure out what's wrong: (line highlighted in red)
Thanks in advance!
I'm getting the following error in my code and can't figure out what's wrong: (line highlighted in red)
Rich (BB code):
Sub ImportGoogleSheet()
Dim URL, Location, FileName As String
Dim objWeb, objWrite As Object
URL = "Google Sheets URL Location"
Location = ThisWorkbook.Path & "\C:\Users\Username\Desktop\Exports"
FileName = "\GoogleSheet.csv"
'Connection to website
Set objWeb = CreateObject("MSXML2.XMLHTTP.3.0")
'Connecting to the website
objWeb.Open "Get", URL, False
objWeb.Send (URL)
If objWeb.Status = 200 Then
'Writer
Set objWrite = CreateObject("ADODB.Stream")
objWrite.Open
objWrite.Type = 1
objWrite.Write objWeb.ResponseBody
objWrite.Position = 0
objWrite.SaveToFile Location & FileName, 2
objWrite.Close
End If
End Sub
Thanks in advance!