Challenge: Calling a Web Service (API) Through Excel 2010 VBA

barnetap

New Member
Joined
Feb 20, 2002
Messages
32
Hello all - I'm working on an research project where we want to analyze the sentiment of a large number of small blocks of text. And, yes, I'm all too familiar with the pitfalls of automated sentiment analysis. Setting that aside, I'd like to test out the effectiveness of different APIs on sample text before committing to a specific service. I'm running Excel 2010/XP. Here's the code (I've simplified for the sake of this example):

Code:
Sub SentimentTest()

    Dim XML
    Dim confirmationStatus As Boolean
    Set XML = CreateObject("MSXML2.XMLHTTP")
    
    
    'Confirm Dialogue
    confirmationStatus = MsgBox("Continue?", vbYesNo, "Continue?")
    If confirmationStatus = 7 Then
        Exit Sub
    End If
    
    'Turn off Screen Updates
    Application.ScreenUpdating = False
    
               
        XML.Open "POST", "http://www.viralheat.com/api/sentiment/review.xml?text=i%20dont%20like%20this&api_key=DE0FWC1l3wzcJCDdKL", False
        'XML.setRequestHeader "Content-Type", "content=text/html; charset=iso-8859-1"
        XML.send
        MsgBox XML.responseText
        

End Sub

After executing, I receive the following error on the "XML.send" line:

Run-time error '-2147467259 (80004005)':
Unspecified error

Any ideas on how to rectify?

Thank you!
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,223,630
Messages
6,173,451
Members
452,514
Latest member
cjkelly15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top