Ghost Symbol :-(

G

Greg Maxey

Using Word2007. If I use Insert>Symbol>More Symbols the Symbol dialog box
opens. If I chose as symbol and click "OK" that symbol is inserted in the
document at the IP. If I click "Cancel" or the dialog box "X" option the
dialog box closes. All as expected.

However, when I use this line of VBA code:

Sub MoreSymbols()
Dialogs(wdDialogInsertSymbol).Show
End Sub

All works as expected, except if I click "Cancel" or the dialog box "X"
option a ghost symbol is inserted at the IP. If I select that symbol and
run:

? Asc(Selection.Text) in the Immediate window it returns 0.

I can work around this issue with:

Sub MoreSymbols()
Application.ScreenUpdating = False
With Dialogs(wdDialogInsertSymbol)
Select Case .Show
Case 0
Case Else
Selection.Move wdCharacter, -1
Selection.Delete
End Select
End With
Application.ScreenUpdating = True
End Sub

What is the ghost symbol? Why does it appear? Is there a better
work-a-round or a way to keep it from appearing in the first place?

Thanks.
 
K

Klaus Linke

Hi Greg,

No idea why that ASCII zero appears...
I often use the following code around showing a dialog:

Application.EnableCancelKey = wdCancelDisabled
Dialogs(wdDialogInsertSymbol).Show
Application.EnableCancelKey = wdCancelInterrupt

Haven't tested in Word2007, but I'd guess it would work too.

Klaus
 
G

Greg Maxey

Hi Klaus,

No joy :-(. The ghost still appears using your code with Word2007.

What is ti that your code is supposed to do?
 
K

Klaus Linke

Greg Maxey said:
Hi Klaus,

No joy :-(. The ghost still appears using your code with Word2007.

What is ti that your code is supposed to do?

I thought it got rid of error messages if a user cancelled out of a dialog.
But testing now, in the couple of macros I used it in I can't get any error
without the EnableCancelKey setting, so can't check if it ever had any
effect...

The code was from some VBA book I read, I'm pretty sure. Very possible it
was bogus all along.

The VBA help says it stops the code from being interrupted with Ctrl+Pause,
and it does in fact seem to do just that... and the help also says it should
be used with care since the setting isn't restored automatically when your
code ends.

Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top