Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tjh tjh is offline
external usenet poster
 
Posts: 96
Default command button

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
tjh tjh is offline
external usenet poster
 
Posts: 96
Default command button

Yes, this is exactly what I need. The only change is rather than allowing the
user to assign the macro to run, I would like to place the macro in the code.
So that if the user hits the button it will run the macro that I have
assigned. Having a little trouble with the change, where should I place this
code with in yours?:

ActiveSheet.Shapes("Button 1").Select
Selection.OnAction = "Macro1"



"JE McGimpsey" wrote:

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,


  #4   Report Post  
Posted to microsoft.public.excel.programming
tjh tjh is offline
external usenet poster
 
Posts: 96
Default command button

Got it, nevermind.

Thank You for your help!!!!!!





"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,

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
command button add another command Wanna Learn Excel Discussion (Misc queries) 5 December 7th 08 11:42 PM
Command button AhmetDY Excel Discussion (Misc queries) 1 October 17th 07 11:36 AM
Command Button Freshman Excel Worksheet Functions 6 June 1st 07 07:15 AM
Command Button vs Control Button RGibson Excel Programming 1 October 14th 03 02:24 AM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 06:09 AM.

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"