Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Customizing the toolbar Icon

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Customizing the toolbar Icon

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Customizing the toolbar Icon

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





  #4   Report Post  
Posted to microsoft.public.excel.programming
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







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
Customizing toolbar in Excel2007? mikelee101 Excel Discussion (Misc queries) 1 May 19th 09 07:59 PM
Customizing Excel Toolbar Tate Excel Discussion (Misc queries) 1 April 9th 07 04:43 PM
Customizing Toolbar Buttons Leo Minervini Excel Discussion (Misc queries) 0 April 6th 05 02:17 AM
Customizing toolbar buttons Alex[_18_] Excel Programming 1 February 25th 04 06:32 PM
Customizing Toolbar terri Excel Programming 1 February 11th 04 04:33 PM


All times are GMT +1. The time now is 12:24 PM.

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"