Avatar of AL_XResearch
AL_XResearch
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Excel VBA: Inserting a Symbol

In Excel 2013 from the 'Insert' tab you can select 'Symbol' to 'insert a symbol. This displays a large dialog and allows you to select a dialog.

Does anyone know how to trigger this from VBA ?  I has assumed it was one of the 'Application.Dialogs' screens but I can't find it.
Microsoft OfficeVBAMicrosoft Excel

Avatar of undefined
Last Comment
aikimark

8/22/2022 - Mon
SOLUTION
Rgonzo1971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
AL_XResearch

ASKER
Hi Rgonzo1971,

Thanks for that. It does indeed do what I want -HOWEVER; it only shows the dialog, it doesn't allow me to return a character.

Is there anything less cryptic than 'CommandBars.FindControl(ID:=308)' ? Say for example of the style 'strTest = Application.insertSymbol'.
Rgonzo1971

Sorry afaik it's not possible
AL_XResearch

ASKER
Seems strange that you can't return a character from below command - even if its not very pleasing to the eye !
Sub show_symbol_dlg()
Application.CommandBars.FindControl(ID:=308).Execute
End Sub

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Rgonzo1971

No because it's like a sendkeys it just says open it
AL_XResearch

ASKER
Indeed. I want to add that 'insert this character' functionality into my VBA solution.
AL_XResearch

ASKER
Is there any way to call the Windows Accessory 'Character map' to allow the selection of a character ?

Obviously this would have to be returned to VBA for inclusion.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Bill Prew

Well, easy enough to launch that, just RUN "%windir%\system32\charmap.exe".

And wait for it to end.

The only problem with it is that the user has to decide to do the COPY button while there, so that when it returns you can get the character out of the clipboard.  I don't think there is anyway to know if they did the COPY, to know if the clipboard is the symbol(s), or leftovers from a prior copy.


»bp
Bill Prew

What's your application / use case, perhaps building your own small form to do this would end up being easier and more friendly.  Either of these dialogs are somewhat busy and you can change characters sets etc, which could change the effect unless you are using that info as well...


»bp
AL_XResearch

ASKER
Bill: the tool is basically a text editor and I want the user to be able to insert accented symbols and or bullet points. That is why I ideally want to the use the Excel 'Insert symbol' - especially as there is a 'recently used' list of characters
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
crystal (strive4peace) - Microsoft MVP, Access

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
aikimark

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
aikimark

If you are in Word, you can use
application.Dialogs(wdDialogInsertSymbol).Show

Open in new window

Where wdDialogInsertSymbol = 162

With that in mind, you should be able to instantiate a word.automation object and use a statement like this to display the dialog.
aikimark

Although the dialog shows in Excel with this command, it doesn't seem useful.  You'd need to look at the contents of the current cell after the dialog goes away.
Application.CommandBars.FindControl(ID:=308).Execute

Open in new window

aikimark

Ah Ha!  The secret value of the unpublished intrinsic constant in Excel is 771.
Application.Dialogs(771).Show

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Rgonzo1971

it does not yet solve the problem of getting the character(s) inserted
aikimark

There are two problems using this dialog in Excel
1. It automatically invokes an edit operation on the activecell.  Code is suspended until the dialog window is closed.
2. Unlike the fileselect dialogs, it doesn't retain a value.

My earlier suggestion, using a Word automation object, should allow you to capture the inserted characters in a non-visible document window.