Thread: command button
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default command button

I'm not sure what you mean by "run an additional", but here's a macro
I've used to put a Forms command button (Forms) on the worksheet, and
open the assign macro dialog to allow the user to assign a macro, and
labels the button with the macro name.

Public Sub AddButtonToSheet()
'J.E. McGimpsey 2001-10-13
'Put Forms Command Button on sheet, Format it,
'and assign a macro to it.
Dim oOldSelection As Object
Dim rOldActive As Range
Dim sCaption As String
Set oOldSelection = Selection
If TypeName(oOldSelection) = "Range" Then _
Set rOldActive = ActiveCell
Application.ScreenUpdating = False
With ActiveSheet.Shapes.AddFormControl( _
xlButtonControl, 600, 50, 1, 23)
.ControlFormat.PrintObject = False
With .TextFrame.Characters.Font
.Name = "Verdana"
.FontStyle = "Bold"
.Size = 12
.ColorIndex = 13
.Shadow = False
End With
.Select
Application.Dialogs(xlDialogAssignToObject).Show "try"
sCaption = .OnAction
If Len(sCaption) 0 Then _
Selection.Caption = Mid(sCaption, InStr(sCaption, "!") + 1)
Selection.AutoSize = True
End With
oOldSelection.Select
If Not rOldActive Is Nothing Then rOldActive.Activate
Application.ScreenUpdating = True
End Sub

In article ,
tjh wrote:

Hello,

Is it possible to use a macro to create a command button, which would run an
additional at the users request. Let me know if you need more info.

Thank You,