VBA to pull dictionary definitions from web

carstenp

Board Regular
Joined
May 27, 2010
Messages
148
I'm studying for the GRE and want to make a flash card macro in excel with a list of vocab words. I found this article, but it seems dated and didn't work for me (I don't think that url works anymore). Here's what I've got so far as I try to build up to a function:
Code:
Sub DefineWord()
    'Assemble HTTP Request
    Dim url As String
    Dim WinHttpRequest As Variant
    Set WinHttpRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
    
    'Get the definition from Google's online dictionary:
    url = "https://www.google.com/search?q=Dictionary#dobs=abandon"
    WinHttpRequest.Open "GET", url, False
        
    'Send the HTTP Request
    WinHttpRequest.send
    
    'Print status to the immediate window
    Debug.Print WinHttpRequest.Status & " - " & WinHttpRequest.StatusText


    'Get the definition
    Dim myDefinition As String
    myDefinition = StrConv(WinHttpRequest.responsebody, vbUnicode)
End Sub
But the HTTP request status comes back as "403 - Forbidden". Can anyone help with just this issue before I can move on to trying to parse through all the text?
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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