Share via

Insert Symbol Dialog

Anonymous
2010-07-27T19:54:39+00:00

In Word 2007 if I use Insert>Symbol>More Symbols I am presented with a a dialog with the options “Insert” and “Cancel” at the bottom of the dialog. If I click “Insert” the selected symbol is inserted if I click “Cancel” nothing is inserted (same if you click the “X” in top corner).

If I use the following macro I am presented with a a dialog with the options “OK” and “Cancel” at the bottom of the dialog. If I click “OK” the selected symbol is inserted if I click “Cancel” or the “X” button then a odd symbol (a y with two dots over it) is inserted.

Sub ScratchMaco1()

Dialogs(wdDialogInsertSymbol).Show

End Sub

I thought that by modifying that macro as follows that I would be able to work around this issue:

Sub ScratchMaco2()

With Dialogs(wdDialogInsertSymbol)

 If .Show <> 0 Then

  Selection.Move wdCharacter, -1

  Selection.Delete

 End If

End With

End Sub

Unfortunately this doesn’t work because regardless of which option I select the .Show method returns “-1”

Does anyone know how to display the first dialog (the one with “Insert” and “Cancel”) using VBA or how to detect the user selection in the second dialog to accurately control the insert?

Thanks


Greg Maxey Visit my website at: http://gregmaxey.mvps.org/word\_tips.htm

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

7 answers

Sort by: Most helpful
  1. Anonymous
    2015-02-04T05:12:54+00:00

    Simon,

    Good idea.  I've modified it slightly:

    Sub ScratchMaco1()

    Dialogs(wdDialogInsertSymbol).Show

    'Bug!  Cancelling the dialog inserts an odd symbol that returns 0 when evaluated so:

    If Asc(Selection.Characters.First.Previous) = 0 Then Undo

    End Sub

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-02-04T01:27:28+00:00

    Hi, Greg,

    I met the same problem. It seems that the "odd symbol" mentioned in your post has a ASCII code of "0". So, you may add the following after "Dialogs(wdDialogInsertSymbol).Show"

    Selection.MoveLeft Unit:=wdCharacter, Extend:=True

    If Asc(Selection.Text) = 0 Then ActiveDocument.Undo

    Hope it would be useful.

    -

    Simon

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-07-28T00:16:48+00:00

    Doug,

    Still testing, but this seems to meet the requirments for a custom Insert>Symbols>More Symbols procedure:

    Sub MoreSymbols()

    Application.ScreenUpdating = False

    Dim dlg As Dialog

    Set dlg = Dialogs(wdDialogInsertSymbol)

    With dlg

      .Display

      On Error Resume Next

      Selection.InsertSymbol .CharNum, .Font, True

      On Error GoTo 0

    End With

    Application.ScreenUpdating = True

    End Sub

    Sub InsertSymbols(ByVal Font As String, CN As Long, Optional UNI As Boolean)

    Selection.InsertSymbol Font:=Font, CharacterNumber:=CN, Unicode:=UNI

    End Sub


    Greg Maxey Visit my website at: http://gregmaxey.mvps.org/word\_tips.htm

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2010-07-27T22:13:15+00:00

    Doug,

    Right.  It appears to be a bug.  I don't see anyway to replicate the Insert>Symbols>More Symbols feature.   


    Greg Maxey Visit my website at: http://gregmaxey.mvps.org/word\_tips.htm

    Was this answer helpful?

    0 comments No comments
  5. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2010-07-27T20:11:16+00:00

    Hi Greg,

    Seems like a bug.  Also, the character that is inserted when cancel is used is strange as using Asc(Selection) returns 0.

    -- Hope this helps.

    Doug Robbins - Word MVP,

    dkr[atsymbol]mvps[dot]org

    Posted via the Community Bridge

    "Greg Maxey" wrote in message news:*** Email address is removed for privacy ***...

    In Word 2007 if I use Insert>Symbol>More Symbols I am presented with a a dialog with the options “Insert” and “Cancel” at the bottom of the dialog. If I click “Insert” the selected symbol is inserted if I click “Cancel” nothing is inserted (same if you click the “X” in top corner).

    If I use the following macro I am presented with a a dialog with the options “OK” and “Cancel” at the bottom of the dialog. If I click “OK” the selected symbol is inserted if I click “Cancel” or the “X” button then a odd symbol (a y with two dots over it) is inserted.

    Sub ScratchMaco1()

    Dialogs(wdDialogInsertSymbol).Show

    End Sub

    I thought that by modifying that macro as follows that I would be able to work around this issue:

    Sub ScratchMaco2()

    With Dialogs(wdDialogInsertSymbol)

    If .Show <> 0 Then

      Selection.Move wdCharacter, -1

      Selection.Delete

    End If

    End With

    End Sub

    Unfortunately this doesn’t work because regardless of which option I select the .Show method returns “-1”

    Does anyone know how to display the first dialog (the one with “Insert” and “Cancel”) using VBA or how to detect the user selection in the second dialog to accurately control the insert?

    Thanks

    -- Greg Maxey Visit my website at: http://gregmaxey.mvps.org/word_tips.htm


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org

    Was this answer helpful?

    0 comments No comments