View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.programming
HSalim[MVP] HSalim[MVP] is offline
external usenet poster
 
Posts: 70
Default Creating an add-in

Finally got it working. It is not quite waht I expected to see .
I never did get the setIcon routine to work, not did the .Picture and .Mask
methods work

This is what I did.
1. added a new Picturename column to my template.
2. Pasted the button image as a picture in the worksheet
3. Asigned a name for each picture

It appears that I can copy the image to memory and the paste the button
image on to the new button using .paste so here is the code snippet.

Regards
Habib



'---------------------
Sub Auto_Open()
Dim cBar As CommandBar
Dim i As Long, cel As Range
Dim ob As Office.CommandBarButton
Dim ws As Worksheet

'On Error GoTo 0
'On Error Resume Next
Set ws = Worksheets(1)

Set cBar = Application.CommandBars("LockBox")
If Not cBar Is Nothing Then

' If cBar.Controls.Count < 2 Then
cBar.Delete
Set cBar = Nothing
'End If
End If

If cBar Is Nothing Then
Set cBar = Application.CommandBars.Add(Name:="LockBox")
cBar.Visible = True

For Each cel In ThisWorkbook.Worksheets("Sheet1").Range("Buttons")
cBar.Controls.Add Type:=msoControlButton
With cBar.Controls(cel.Value)
.OnAction = cel.Offset(, 1).Value
.Caption = cel.Offset(, 2).Value
.TooltipText = cel.Offset(, 3).Value
.Style = msoButtonIconAndCaption
ws.Shapes(cel.Offset(, 4).Value).CopyPicture xlScreen,
xlBitmap
.PasteFace
.BeginGroup = True
End With
Next
End If

cBar.Enabled = True
cBar.Position = msoBarTop
End Sub

'--------------------------------------

"HSalim[MVP]" wrote in message
...
: Peter,
: It was not the file size that concerened me.
: I just did not like the idea of having those image files outside - now I
had
: to be converned with handling errors if those files were deleted -
troubles
: with ensuring a consistent user experience etc...
:
: Looks like you have a bit of experience in this area, huh!
: Thanks for the help.
:
: Regards
: Habib
:
: :