Toolbars

J

Jerry Bodoff

Hi,

Is there any way to put a "custom" toolbar on a User
Form? I have a "custom" floating toolbar that I would
like to also put at the bottom of a form.

Any help or a link to a document would be appreciated.

Thanks in advanced.

Jerry Bodoff
 
J

Jay Freedman

Hi Jerry

I don't think you can literally place a toolbar on a userform, but you
can fake it with an image control that contains a picture of the
toolbar. Then use code like this to respond to clicks:

Private Sub Image1_MouseDown( _
ByVal Button As Integer, ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)

' adjust next line for number of buttons on image
Const NumButtons = 5
Dim ButtonIdx As Integer

' compute which button
ButtonIdx = Int(NumButtons * (X / CSng(Image1.Width))) + 1

' call appropriate "event procedure"
Select Case ButtonIdx
Case 1
Call ClickedButton1
' Case 2
' Call ClickedButton2
' etc.
Case Else
End Select
End Sub

Private Sub ClickedButton1() ' pseudo-event
MsgBox "Clicked button 1"
End Sub

' etc.

If you want to get really fancy, you can have separate images showing
each of the buttons pressed in, and swap them in as part of the
respective click procedures. This probably won't work if you need to
send the template to others, though, because the only way I see to put
pictures into an image control at run time is to use the LoadPicture
function, which requires an external graphics file.
 
J

Jerry Bodoff

Hi Jay,

Thanks for the solution.

I tried using the toolbar from the toolbox but so far I
cannot make it look decent and it seems that you cannot
do a lot with it. It continually amazes me that
Microsoft does not supply some common tools for VBA
(which I think a toolbar is, also a grid control would be
nice for tables). I think your solution is clever and I
will do it that way.

Once again thanks a lot for your reply.

Jerry B.
 

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