How to send the data to google sheet in excel using VBA in MacBook?

Kasen Wong 1 Reputation point
2021-01-15T03:40:35.073+00:00

Hi everyone,

I found a tutorial on Youtube showing me how to do send the data to Google sheet using VBA. The method works perfectly in Window PC but it have some problem with MacBook. When I run the Macro in MacBook, it will show me that "Can't find project or library". After doing some research, I found out that it is actually the problem of MSXML2.ServerXMLHTTP60 which doesn't exit in MacBook (if I'm correct). I'm not sure how to solve this issue as I'm relatively new to VBA and I'm not coming from a technical background with strong understanding on "server". I posted the code below and hope to get some advice on what should I change so that it works for both Window and MacBook.

In case someone needs the Youtube video, here is the link:
https://www.youtube.com/watch?v=yr9UzELXG8M&lc=UgzMtGWrOSnS_tYcdZt4AaABAg.9IRuFuAy9i69ITfF1fxcPV

Of course, if any one of you have better idea on how to send the data to Google sheet which works for both Window and MacBook, please let me know by leaving a comment. Really appreciate if someone can help me to solve this problem.

Sub SendTicket()
'This Macro Requires Reference to "Microsoft XML, v6.0" (VBA Editor > Tools > References, find & select from list)
'Created By Randy Austin of www.ExcelForFreelancers.com
'https://docs.google.com/forms/d/e/1FAIpQLScaXsTsNxWDNxg4CuMIpm3uKy4aFFm8aC8Fw2pzhSYZN8snTA/viewform?usp=pp_url&entry.1301421684=TestName&entry.606095064=******@email.com&entry.2080720803=VBA+Bug&entry.1773665967=TestDesc
Dim SendLink As String, StartLink As String, EndLink As String, HeaderName As String, SendID As String
Dim ReportedBy As String, EmailAdd As String, IssType As String, IssDesc As String
Dim TicketInfo As MSXML2.ServerXMLHTTP60
HeaderName = "Content-Type"
SendID = "application/x-www-form-urlencoded; charset=utf-8"
'Get Form  Details
ReportedBy = SubmitTicketForm.SenderName.Value 'Reported By Name
EmailAdd = SubmitTicketForm.SenderEmail.Value 'Reported By Email Address
IssType = SubmitTicketForm.IssueType.Value 'Issue Type
IssDesc = SubmitTicketForm.Description.Value 'Issue Description

    'Please update the links with your own link from Google Forms
    StartLink = "https://docs.google.com/forms/d/e/1FAIpQLScaXsTsNxWDNxg4CuMIpm3uKy4aFFm8aC8Fw2pzhSYZN8snTA/formResponse?ifq"
    EndLink = "&entry.1301421684=" & ReportedBy & "&entry.606095064=" & EmailAdd & "&entry.2080720803=" & IssType & "&entry.1773665967=" & IssDesc & "&submit=Submit"
    SendLink = StartLink & EndLink

    Set TicketInfo = New ServerXMLHTTP60
    TicketInfo.Open "POST", SendLink, False

    TicketInfo.setRequestHeader HeaderName, SendID
    TicketInfo.send

    If TicketInfo.statusText = "OK" Then 'Check for successful send
        MsgBox "Thank you for submitting a ticket. We will email you a response shortly"
    Else
        MsgBox "Please check your internet conenction & required details"
    End If
End Sub
Developer technologies | Visual Basic for Applications
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.