How do you modify an existing Template/Toolbar

  • Thread starter Charles of the Randstaad
  • Start date
C

Charles of the Randstaad

I have an existing Template which when launched appears as
a Toolbar in MS WORD.

The Template includes the following line:

Sub InsertGuillemetFermantSimple()
Selection.InsertSymbol Font:="TimessPP",
CharacterNumber:=8217, Unicode:=True
End Sub

The corresponding character appears on the toolbar and all
the user does is click on it to insert the character in
the MS WORD document.

With no background in VBA, I thought I could add another
line to insert CharacterNumber:=8213.

This is what I did: I copied the existing line for
CharacterNumber:=8217 and manually made changes to it:

This is what I get:

Sub InsertHorizontalBar()
Selection.InsertSymbol Font:="TimessPP",
CharacterNumber:=8213, Unicode:=True
End Sub

When I run this Sub/UserForm from the VBA Editor, it
inserts the correct character in MS WORD.

Question 1: What is the procedure for making the character
appear in the toolbar?

Question 2: What is the CharacterNumber for the « or the
LEFT-POINTING DOUBLE ANGLE QUOTATION MARK or Guillemet
Gauche?

I have added this line:

ub InsertGuillemetGauche ()
Selection.InsertSymbol Font:="TimessPP",
CharacterNumber:=00AB, Unicode:=True
End Sub

When I try to compile it, I get a syntax error.
When I try to run it, I get an end of line error showing
there is an error at the AB level.

What is a beginner to do?

Charles
 
R

Randy Birch

That is a hex code and requires a hex prefix ...

Option Explicit

Sub InsertGuillemetGauche()
Selection.InsertSymbol Font:="TimesPP", CharacterNumber:=&HAB,
Unicode:=True
End Sub


--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.


message I have an existing Template which when launched appears as
a Toolbar in MS WORD.

The Template includes the following line:

Sub InsertGuillemetFermantSimple()
Selection.InsertSymbol Font:="TimessPP",
CharacterNumber:=8217, Unicode:=True
End Sub

The corresponding character appears on the toolbar and all
the user does is click on it to insert the character in
the MS WORD document.

With no background in VBA, I thought I could add another
line to insert CharacterNumber:=8213.

This is what I did: I copied the existing line for
CharacterNumber:=8217 and manually made changes to it:

This is what I get:

Sub InsertHorizontalBar()
Selection.InsertSymbol Font:="TimessPP",
CharacterNumber:=8213, Unicode:=True
End Sub

When I run this Sub/UserForm from the VBA Editor, it
inserts the correct character in MS WORD.

Question 1: What is the procedure for making the character
appear in the toolbar?

Question 2: What is the CharacterNumber for the « or the
LEFT-POINTING DOUBLE ANGLE QUOTATION MARK or Guillemet
Gauche?

I have added this line:

ub InsertGuillemetGauche ()
Selection.InsertSymbol Font:="TimessPP",
CharacterNumber:=00AB, Unicode:=True
End Sub

When I try to compile it, I get a syntax error.
When I try to run it, I get an end of line error showing
there is an error at the AB level.

What is a beginner to do?

Charles
 
J

Jay Freedman

Hi, Charles,

The procedure for creating a custom toolbar button to run a macro is
described at
http://word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm.

In the macro for the guillemet gauche, the CharacterNumber must be
given as the decimal number 0171; the value 00AB is the equivalent
hexadecimal number. You can use the Calculator program in the Windows
Start > Programs > Accessories menu to do the conversion, after
setting it to View > Scientific.

By the way, you can assign a shortcut key to any character, instead of
using a macro and a button. In the Insert > Symbol dialog, select the
font and the character, then click the Shortcut Key button and make an
assignment.
 
G

Guest

Hi Jay,

Thanks for the characternumbers. I inserted them and by
clicking Run Sub/UserForm, the symbol is inserted in my
document. That was only part of my problem.

As I stated in my original mail, when launched my .dot
template appears on screen as a toolbar.

My question is, how do I insert these symbols (», « ―)
into the template so that by clicking on any of them, the
corresponding character is inserted in the document.

Charles
 
J

Jay Freedman

Hi, Charles,

I was concentrating on the syntax error and missed the other part.

Are you asking how to make each button on the toolbar show the
character that it inserts? That's not too difficult.

First follow the procedure in
http://word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm to
make the buttons. They'll be labeled with the names of the macros.

Click one of the buttons to put the corresponding symbol into the
document. Select the symbol and cut it to the clipboard. Open the
Tools > Customize dialog (a very quick shortcut is to double-click any
blank area to the right of the Standard or Formatting toolbar). While
that dialog is open, right-click the symbol button, select the entire
contents of the Name box on the popup, and paste in the symbol from
the clipboard to replace the macro name. Press Enter, and close the
Customize dialog. Repeat all of this for each button (you must close
the Customize dialog each time in order to be able to insert and cut
the next symbol).
 

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