View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
STEVE BELL STEVE BELL is offline
external usenet poster
 
Posts: 692
Default Command Button in Excel

Dave,

Appreciate your concern.

I do like leading and trailing spaces for the text in a button.
Gives me a little separation between buttons on the bar.

The spaces in the names should be removed. I agree - all names
are best without any spaces.
(This code was copied into a master source workbook that
I keep special code in for reference - guess it's time to review
some of this stuff and clean it up)

--
steveB

Remove "AYN" from email to respond
"Dave Peterson" wrote in message
...
Do you really use leading and trailing spaces in your commandbars names?

That would confuse me when I was just looking at the name.

But, heck, I don't even like spaces in there!



STEVE BELL wrote:

Frederic,

Here is some general code to add/delete command bars.
(be sure to fix word wrap)

Use the workbook open (or workbook activate) event to creat the bar
Use the workbook close (or workbook deactivate) event to delete the bar

Sub CommandBarCreate()
'NewToolBar()
Dim cbrCommandBar As CommandBar
Dim cbcCommandBarButton As CommandBarButton

' If the command bar exits, remove it.
On Error Resume Next
Application.CommandBars(" APW Convert ").Delete

' Add the command bar to the application's
' CommandBars collection.
Set cbrCommandBar = _
Application.CommandBars.Add
cbrCommandBar.Name = " APW Convert "

' Add command button control to the control's
' collection of CommandBar objects.
With cbrCommandBar.Controls
Set cbcCommandBarButton = _
.Add(msoControlButton)

' Set properties of the command button.
With cbcCommandBarButton
.Style = msoButtonIconAndCaption
.Caption = " APW Convert "
.FaceId = 1
.TooltipText = _
"Press me to convert APW."
.OnAction = "apwConvert"
.Tag = "apwconvert"
End With

End With
cbrCommandBar.Visible = True
cbrCommandBar.Left = 125
cbrCommandBar.Top = 150

End Sub

Sub CommandBarDelete()
Application.CommandBars(" APW Convert ").Delete
End Sub

--
steveB

Remove "AYN" from email to respond
"Frederic" wrote in message
...
I have a command button on the toolbar of my excel spreadsheet. However
I
need to send this spreadsheet out to other people and once sent to
them,
the
command button doesn't appear on their toolbar. Is there a way of
making
it
happen, or even better is there a way of having the command button in
the
spreadsheet (I mean in one cell)?
Any advise, help would be greatly appreciated.


--

Dave Peterson