Tags:
  1. Hammer

    Hammer Moderator Staff Supporter Contributor

    Joined:
    Oct 28, 2018
    Messages:
    2,262
    Likes Received:
    4,015
    Location:
    UK

    Try these word macros...(a bit geeky)

    Discussion in 'Writing Software and Hardware' started by Hammer, Dec 4, 2018.

    Afternoon world,

    I thought I would share three simple word macros which I love. If you don't know how to edit a macro in word, this probably isn't for you (although all you need to do is create a macro, open it to edit, and paste the code below into the "new macros" module in normal.dot), but if you do this little bit of code is just beautiful - I have it assigned to keyboard shortcuts so I can just highlight a word in a document and hit

    ctrl + g to google it
    ctrl + d to look it up in the Oxford dictionary
    ctrl + t to look it up in the thesauraus (I like thesaurus.com)


    Declare Function ShellExecute _
    Lib "shell32.dll" _
    Alias "ShellExecuteA" ( _
    ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) _
    As Long



    Sub DictionarySearch()

    Dim stUrl
    Dim stWord

    stWord = ActiveWindow.Panes(1).Selection

    stUrl = "https://en.oxforddictionaries.com/definition/" & stWord


    ShellExecute 0, "OPEN", stUrl, "", "", 0

    End Sub

    Sub GoogleIt()

    Dim stUrl
    Dim stWord

    stWord = ActiveWindow.Panes(1).Selection

    stUrl = "https://www.google.co.uk/#q=" & stWord

    ShellExecute 0, "OPEN", stUrl, "", "", 0

    End Sub

    Sub ThesaurusSearch()

    Dim stUrl
    Dim stWord

    stWord = ActiveWindow.Panes(1).Selection

    stUrl = "http://www.thesaurus.com/browse/" & stWord

    ShellExecute 0, "OPEN", stUrl, "", "", 0

    End Sub
     
  2. LazyBear

    LazyBear Banned

    Joined:
    Oct 27, 2017
    Messages:
    374
    Likes Received:
    231
    Location:
    Uppsala, Sweden
    There are also word lists that can be downloaded, which will remain even if the sites change their URL parsing, and won't accidentally be flagged as a DOS attack. I used one in a VB.NET application a few years years ago. It sounds like a lot of data, but it's only a few megabytes for the whole English language and it processes quickly if you store it as a character tree.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice