Sunday, September 20, 2015

WIKI Search in Excel with VBA

Here's a VBA code snippet for searching a string in a cell in WIKIPEDIA:

Sub wiki()

Dim searchstr As String
Dim searchsadd As String

searchstr = ActiveCell.Value
searchadd = "http://en.wikipedia.org/w/index.php?title=Special%3ASearch&profile=default&search=" & searchstr & "&fulltext=Search"

If Len(searchstr) = 0 Then
MsgBox "The active cell is empty.. Nothing to search for..", vbOKOnly, "WIKIPEDIA"

Else:
ActiveWorkbook.FollowHyperlink searchadd, NewWindow:=True
Application.StatusBar = "WIKI search for: " & searchstr
End If

End Sub

No comments:

Post a Comment