Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Custom face on a button without using clipboard?

I want to put a custom face on a button. Is the only way to do this
PasteFace? Can I not just specify a file path for the image.

The problem is I set up these toolbars on startup and dont want to clear
the clipboard.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Custom face on a button without using clipboard?



IF you program for xlXP and newer:

You can use the Picture and Mask properties of the commandbarcontrol
I use an imagelist control to store the bitmaps.
(you'll need 2 for each icon)..
I use ArtIcons Pro (from aha-soft.com), which has an option
to export bitmaps AND masks.

(make sure they are 16x16 and 24bit or 256 color,
DO NOT USE 32bit icons)


the imagelist control can be in a userform or embedded on a sheet.

for older versions I prefer to store my icons in an embedded Forms Image
control. (Streched/No Borders,Backcolor ButtonFace) rather then as an
Excel.Picture.. gives less distortion and sharper image with partly
transparent icons.

Option Explicit

Const csAPP = "my application"
Const csTAG = "myAPPid"
Const csMNU = "custom userform"

Private Sub Auto_Open()
doMenu True
End Sub

Private Sub Auto_Close()
doMenu False
End Sub

Private Sub doMenu(fDo As Boolean)
Dim cCtl As CommandBarControl

On Error Resume Next
With Application.CommandBars
Do
Set cCtl = .FindControl(ID:=0, Tag:=csTAG)
If Not cCtl Is Nothing Then cCtl.Delete
Loop Until cCtl Is Nothing
If Not fDo Then Exit Sub

'Use the Tools Menu
Set cCtl = .FindControl(ID:=30007).Controls.Add( _
Type:=msoControlButton, Temporary:=True)
cCtl.Tag = csTAG
cCtl.Caption = csMNU
cCtl.OnAction = ThisWorkbook.Name & "!doForm"
cCtl.FaceId = 59
cCtl.Style = msoButtonAutomatic
'Customize Icon
doIcon cCtl
'Make a copy on the Standard bar :)
With cCtl.Copy(Bar:=Application.CommandBars("Standard") )
.Caption = csAPP
.Style = msoButtonIcon
End With
End With
End Sub


Private Sub doIcon(ByVal btn As CommandBarButton)
Dim pic As Object
If Val(Application.Version) < 10 Then
ThisWorkbook.Worksheets(1).Shapes("image1").CopyPi cture
btn.PasteFace
ThisWorkbook.Worksheets(1).Range("iv65536").Copy
Application.CutCopyMode = False
Else
'This will be run by xlXP+ only.
'CallByName is used to avoid compile errors in xl2k

#If VBA6 Then
Set pic = ThisWorkbook.Worksheets(1) _
.OLEObjects("imagelist1").Object
CallByName btn, "Picture", VbLet, pic.ListImages("pict").Picture
CallByName btn, "Mask", VbLet, pic.ListImages("mask").Picture
#End If
End If
End Sub

Public Sub DoForm()
MsgBox "Hi"
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"?B?TmlnZWw=?=" wrote:

I want to put a custom face on a button. Is the only way to do this
PasteFace? Can I not just specify a file path for the image.

The problem is I set up these toolbars on startup and dont want to
clear the clipboard.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Custom face on a button without using clipboard?

See possible answer to later posting of this question.

--
Regards,
Tom Ogilvy

"Nigel" wrote in message
...
I want to put a custom face on a button. Is the only way to do this
PasteFace? Can I not just specify a file path for the image.

The problem is I set up these toolbars on startup and don't want to clear
the clipboard.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Custom face on a button without using clipboard?


Cheers I'll give it a try. As for 3 postings it kept saying it failed bu I
guess not!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
change the face color of an Excel command button Chris Leah Excel Discussion (Misc queries) 5 April 21st 23 09:03 AM
2003 - 2007 custom macro and custom button restore. Scott Sornberger Excel Discussion (Misc queries) 11 May 23rd 08 02:41 PM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM
Add-in with custom Face R Avery Excel Programming 2 March 5th 04 03:34 PM
Inserting a Face ID onto a Command button Denny Behnfeldt Excel Programming 5 February 12th 04 01:59 PM


All times are GMT +1. The time now is 11:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"