PDA

View Full Version : Solved: Pre-filling InsertSymbol Dialog



Paul_Hossler
09-13-2009, 12:49 PM
Trying to have the InsertSymbol dialog open with the Normal font pre-selected (plus others like Hex, etc)

Code below keeps the previous manually selected Font name, not the one for the Normal style

What am I doing wrong?


Option Explicit
'ref: http://msdn.microsoft.com/en-us/library/aa211930(office.11).aspx
' http://msdn.microsoft.com/en-us/library/aa211931(office.11).aspx
Sub InsertUnicode()
Dim dlg As Dialog
Set dlg = Application.Dialogs(wdDialogInsertSymbol)

'wdDialogInsertSymbol Font, Tab, CharNum, CharNumLow, Unicode, Hint
With dlg
MsgBox ThisDocument.Styles("Normal").Font.Name
.Font = ThisDocument.Styles("Normal").Font.Name
.Update
.Display
' .Execute
' .Show
End With

Stop
End Sub


Thanks

Paul

fumei
09-14-2009, 11:51 AM
Gee Paul, it sure seems like you are doing nothing wrong. It appears that you can not do this. I can not get it to change either. I was wondering if it needed an explicit SubSet, but I can not find anyway to give it that parameter.

Which is rather annoying, because the last manual values must be somewhere. However, it looks like it is one of those values that are deep inside Word, and not exposed to VBA. There are a few. For example, I manually changed the Font to Tekton and the Subset to Arabic Extended.

Now (as you know) THAT is what comes up with the InsertSymbol dialog. If I change it to Times Roman and Basic Latin subset, then THAT is what comes up when the dialog is opened again. So those values are stored somewhere. But it sures looks like they are not exposed to VBA.

Why are you trying to do this?

Paul_Hossler
09-14-2009, 02:31 PM
From Help: Inserting Unicode characters

To insert a Unicode character, type U, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X. For more Unicode character codes, see Unicode character code charts by script (http://r.office.microsoft.com/r/rlidAWSContentRedir?AssetID=XT103510871033&CTT=11&Origin=HA101675391033).



InsertSymbol is the only way I know to insert the 'higher order' characters from a Unicode font by 'picking' the character.

So if the Normal font is Unicode, I just wanted to have InsertSymbol open with the Normal font selected, instead of WingDings, etc.

The settings are persistent, but since I change to different templates a lot, it just seems like a simple thing to do, making my life just a tad easier.

Other suggestions?

Paul

fumei
09-16-2009, 08:53 AM
Yes, but InsertSymbol is a method. I do not understand why you are using a dialog, rather than the method itself.

Even Microsoft itself suggests that if there is a direct method to do something, it much better to use that, rather than any dialog.

Can you explain: "if the Normal font is Unicode"? I do not know what you mean by that.

Can you give an explicit example of what you are trying to do?

Paul_Hossler
09-16-2009, 12:20 PM
Some fonts have the 2 byte unicode characters (e.g. Arial Unicode MS), but even if the Normal font is not a unicode font, I wanted the InsertSymbol dialog to just be pre-configured with the Normal font.

Like in the attachment, with Arial Unicode MS as Normal, 21B9, Alt-X inserts the LEFTWARDS ARROW TO BAR OVER RIGHTWARDS ARROW TO BAR character

I wanted to

1. Use the .Dialog to open the InsertSymbol dialog box to allow me to pick the character to be inserted.

2. Have the InsertSymbol dialog box configured to the current Normal style font.

3. Insert the chosen character(s)

fumei
09-16-2009, 01:15 PM
You are stuck on #2. I do not think this is possible. Yes, you can open the InsertSymbol dialog via code. You just can not change the configuration via code.

However, there is (in my mind) a conflict of intent here.

You want to create a dialog object (by code), and display it (by code), change its configuration (by code)...then have the user (you?) manually select the symbol...then insert that by code.

I think you are stuck with this one. Although if someone can find where those darn values are stored then that is another story. Values that are exposed to VBA are just that. If they are exposed, then they can be altered (if they are not read-only, and obviously these are not).

However, I can not find them anywhere in the Object Model. So I think you are SOL.

"Like in the attachment, with Arial Unicode MS as Normal, 21B9, Alt-X inserts the LEFTWARDS ARROW TO BAR OVER RIGHTWARDS ARROW TO BAR character"

You misunderstand. This has nothing to with Normal. You can have Normal be using Times New Roman (as its Font) and 21B9, Alt-X will still insert that character.
With Selection
.TypeText Text:="21B9"
.ToggleCharacterCode
End With
will also insert that symbol (at the Selection point).

Paul_Hossler
09-16-2009, 05:33 PM
You're correct, but the reason I wanted to display the box is to allow me to pick the glyph I want to be inserted without having to know the unicode value.

As your example shows, VBA can use a method to insert a known unicode value, if I want to insert the same glyph.

Similarly, the Alt-x will allow me to insert any known unicode value via the keyboard, if I know the unicode value.

While both are helpful, they require knowing the unicode value (and my memory is not that good):whistle:

The dialog box allows me to see the glyph and pick the one(s) to be inserted.

The reason I was trying to get the InsertSymbol font set to Normal was because I usually only use glyphs in the font currently set as Normal (but as I think about it, it'd be better to set it to the Selection point font instead):think: , and it was a minor convienance that I thought would be easy.

Hope I explained my objective more clearly

Paul

fumei
09-17-2009, 08:31 AM
True, very true. You have to know the unicode. And, if you do not, then again, I think you are SOL in terms of altering the dialog box as you want to. I see no way to open the dialog as you intent.

Paul_Hossler
09-17-2009, 02:53 PM
Ok - thanks

At least I now know to give up:banghead:

Paul

fumei
09-21-2009, 08:31 AM
Oh, and if you ever DO find a way, let us know!