View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Customizing the toolbar Icon

It's really annoying to start Excel and ......
I agree with you Rob

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Rob van Gelder" wrote in message ...
Beware of the CopyPicture method if you are using it to build a toolbar on startup. You lose what was previously on the clipboard.

It's really annoying to start Excel and go to paste some data but instead pastes a small graphic.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Bob Phillips" wrote in message ...
Copy your button face, and then paste it into a worksheet in the add-in.
You can then use it in the toolbar like so

wsHistory.Shapes("fxGenIcon").CopyPicture
.PasteFace

where wsHistory is the codename of the worksheet with the graphic on it.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"BigOil" wrote in message
om...
I am creating a custom Add-in that creates a toolbar on the users
excel. However, I want to create a custom icon by right-clicking on
the toolbar and then editing the image. When I do this however, the
next time I open excel, the customized image I created is lost. How
can I get it to save my cusome Image? Here is the code I used to
create the toolbar:


Sub CreateNewCommandBar()

Dim lcb_Bar As CommandBar

'' Delete any pre-existing CommandBar that uses our name
DeleteCommandbar gStr_CbarName

'' Set a reference to the CommandBar we create
Set lcb_Bar = CommandBars.Add(Name:=gStr_CbarName,
Position:=msoBarTop, Temporary:=True)

'' Create the controls

''Add AFE button
Dim AFE_button As CommandBarButton
Set AFE_button = lcb_Bar.Controls.Add(Type:=msoControlButton)
With AFE_button
.Style = msoButtonIconAndCaption
.Caption = "Get AFE Data"
.OnAction = "Get_AFE"
End With
''Add CC button
Dim CC_button As CommandBarButton
Set CC_button = lcb_Bar.Controls.Add(Type:=msoControlButton)
With CC_button
.Style = msoButtonIconAndCaption
.Caption = "Get CC Data"
.OnAction = "Get_CC"
End With

'' Ensure it is visible
lcb_Bar.Visible = True


End Sub

Function DeleteCommandbar(pStr_CbName As String) As Boolean
Dim x
Dim lBoo_tf As Boolean

lBoo_tf = False

For Each x In Application.CommandBars
If pStr_CbName = x.Name Then
x.Delete
lBoo_tf = True
End If
Next

End Function