How Can I Insert a Symbol into a Word Document?

How Can I Insert a Symbol into a Word Document?

  • Comments 5
  • Likes
Hey, Scripting Guy! Question

Hey, Scripting Guy! How can I insert a Wingding symbol into a Word document?

-- RC

SpacerHey, Scripting Guy! AnswerScript Center

Hey, RC. In case you’re wondering, there were two reasons why we decided to answer your question. First, we just liked the phrase insert a Wingding symbol. (No, we don’t know why we liked it, we just did.) Second - and by far most important - this is an easy one, one we can answer with just a few lines of code.

As we’ll see, the code for inserting a symbol into a Word document is trivial; what’s tricky is figuring out which symbol you want to insert (as well as the character code for that symbol). Perhaps the easiest way to do this (although we’ll show you another method at the end of today’s column) is to open up the Symbol dialog box, select the desired font, and then click on the symbol you want to insert:

Microsoft Word Symbols


As you can see, we’ve selected the smiley face. When we do so, the character code for the smiley face is listed in the Character code box. Now that we know the font we want to use (Wingdings) and the character code for our symbol (74), we’re ready to write a script that inserts the smiley face into a Word document:

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

objSelection.InsertSymbol 74, "Wingdings"

We told you the code was trivial. We begin by creating an instance of the Word.Application object, and then set the Visible property to True. We call the Add() method to create a new document, then create an instance of the Word Selection object.

At that point all we need is one line of code in order to insert the smiley face symbol:

objSelection.InsertSymbol 74, "Wingdings"

That’s it: we call the InsertSymbol method followed by the desired character code and the desired font. Run the script, and you should see a smiley face in your document. (It is a miracle, isn’t it?)

If you like using symbols it might be worth your while to create a catalog of symbols and their character codes. Here’s a script that creates a Word document containing all the symbols and their character codes found in the Wingdings font (character codes 32 through 255). You can easily modify the script to give yourself a catalog of symbols for Wingdings2, Wingdings3, Webdings, Bookdings, and any other ding-dang font you want.

Here’s the code:

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

For i = 32 to 255
    objSelection.TypeText i & " -- "
    objSelection.InsertSymbol i, "Wingdings"
    objSelection.TypeParagraph()
Next

And here’s what the resulting document looks like:

Microsoft Word Symbols


It’s not quite the IKEA catalog, but it’s close.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • how do u make a love heartv then??????????????????/      

  • Hi,

    Word 2007 is supposed to turn :) into a smiley face. It's also supposed to turn -- into a long dash, but my Word doesn't. I checked the Autocorrect options and it says that they are all on, and that :) should turn into a smiley face, but it doesn't. I've tried it in many fonts and sizes but it doesn't work. Does anyone know how to solve this problem?

  • Nevermind, got question that I posted above solved. All you need to do (if anyone else has this problem) is check replace as you type in Autocorrect Settings.

  • @Someone thanks for writing. When you described the problem, I immediately thought of autocorrect ... correct as I type did not spring to mind ... thanks for the follow up.

  • we need to know how to turn words into emoticons!!!