creating a toolbar button to use style or autotext

B

Birgit

Hi all,
I want to create a button on a custum toolbar that will allow the user to
use a style or autotext in the document. I know how to do this by hand, but
I want to do this now using VBA. The button is not supposed to call a macro
(as I do not want the template to contain macro's).

Any pointers?

This is what I have, but the button sadly does nothing... (ultimately I will
use customizationcontext to attach the toolbar to the right document)

Dim mybar As CommandBar
Dim mycontrol As CommandBarButton
Set mybar = activedocument.CommandBars.Add("mydoc")
Set mycontrol = mybar.Controls.Add(Type:=msoControlButton)
With mycontrol
.Caption = "Normal"
.Parameter = "normal"
.Style = msoButtonCaption
End With
 
G

Graham Mayor

How is the button going to work if the template does not contain any (vba)
macros?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

Birgit

How is the button going to work if the template does not contain any (vba)

Hi Graham,

If you add a button manually and you choose from the customize menu "styles"
or "autotexts" instead of macros it works. That is exactly what I want to
achieve.

I generate documents and templates (that normally do not contain any code,
just styling and text). Now I also would like to generate the toolbar that
goes with a (macro-free) template.

Ah, I generate the templates from a different document that contains the
code for it all. Once the document/template is created I only keep the code
in case there will be any changes.

BTW, forgot to mention that this concerns Word 2003 at this moment.

I'm not sure if you can customize the 2007 ribbon without any code. At least
if you want to have buttons that do something. I have been adding code to
use styles there, but I know Word 2003 can do without.

Cheers,
Birgit
 

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