How to add on toolbar button for start some program?

A

avkokin

Hello.
I wonder it there is a way to add on toolbar the button for start some
program e.g. NOTEPAD.EXE (from folder Windows)?
Thank you very much.
 
H

Helmut Weber

Hi Anton,
I wonder it there is a way to add on toolbar the button for start some
program e.g. NOTEPAD.EXE (from folder Windows)?

programmatically?

Or is it just about the code to start an application
other than an office application,
though it would work with an office application, too.

For notepad, e.g.:

Sub Notepad()
Shell "c:\windows\notepad.exe", 1
End Sub

Then goto "tools, customize, commands".
In the left listbox scroll to "macros".
Locate your macro "notepad" in the right listbox.
Select it, drag it to a commandbar,
and drop it there.
Then right mouseclick and choose
"Default style"
Then right mouseclick and choose
"change button image"
or
"Edit button image"
then ;-)
have some fun, its endless.
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
H

Helmut Weber

Hi Anton,

I have received your email.

Have a look at that one,
which prevents adding a new button
every time the macro is executed.

Sub Macro10()
Dim bFound As Boolean
Dim Mybar As CommandBar
Dim Mycontrol As CommandBarControl
Set Mybar = CommandBars("Standard")
For Each Mycontrol In Mybar.Controls
If Mycontrol.Type = msoControlButton Then
If Mycontrol.OnAction = "Notepad" Then
bFound = True
End If
End If
Next
If bFound = False Then
Set Mycontrol = Mybar.Controls _
.Add(Type:=msoControlButton)
With Mycontrol
.FaceId = 2 'what faceId is another story
.OnAction = "Notepad"
End With
End If
End Sub
' ---------------------------------------------
Sub Notepad()
Shell "c:\windows\notepad.exe", 1
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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