Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Hard Coding A Button Using "Buttons.Add(x1,x2,x3,x4)"

Hi all,

I'm writing a Excel sheet that requires a button to be inserted for a
certain situation in a macro. I didn't know the instructions to create
a button so i recorded a macro that did what i wanted then looked at
the generated code. The recorded macro gave me this:

ActiveSheet.Buttons.Add(x1,x2,x3,x4)

where x1...x4 are numbers. Does anybody know what these numbers are
for? I can't seem to find it in the help menu.

Thanks
Bill

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Hard Coding A Button Using "Buttons.Add(x1,x2,x3,x4)"

Hi Bill

left
top
width
height


Sub test()
Dim WS As Worksheet
Dim Btn As OLEObject
Set WS = ThisWorkbook.Worksheets("Sheet1")
With WS
Set Btn = .OLEObjects.Add(ClassType:="Forms.CommandButton.1" , _
Left:=.Range("C3").Left, Top:=.Range("C3").Top, _
Width:=100, Height:=30)
End With
Btn.Object.Caption = "Click Me"
Btn.Name = "TheButton"
With ThisWorkbook.VBProject.VBComponents(WS.CodeName).C odeModule
.InsertLines .CreateEventProc("Click", Btn.Name) + 1, _
"Msgbox ""Hi there"" "
End With
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message oups.com...
Hi all,

I'm writing a Excel sheet that requires a button to be inserted for a
certain situation in a macro. I didn't know the instructions to create
a button so i recorded a macro that did what i wanted then looked at
the generated code. The recorded macro gave me this:

ActiveSheet.Buttons.Add(x1,x2,x3,x4)

where x1...x4 are numbers. Does anybody know what these numbers are
for? I can't seem to find it in the help menu.

Thanks
Bill

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Hard Coding A Button Using "Buttons.Add(x1,x2,x3,x4)"

Thanks!

Ron de Bruin wrote:
Hi Bill

left
top
width
height


Sub test()
Dim WS As Worksheet
Dim Btn As OLEObject
Set WS = ThisWorkbook.Worksheets("Sheet1")
With WS
Set Btn = .OLEObjects.Add(ClassType:="Forms.CommandButton.1" , _
Left:=.Range("C3").Left, Top:=.Range("C3").Top, _
Width:=100, Height:=30)
End With
Btn.Object.Caption = "Click Me"
Btn.Name = "TheButton"
With ThisWorkbook.VBProject.VBComponents(WS.CodeName).C odeModule
.InsertLines .CreateEventProc("Click", Btn.Name) + 1, _
"Msgbox ""Hi there"" "
End With
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message oups.com...
Hi all,

I'm writing a Excel sheet that requires a button to be inserted for a
certain situation in a macro. I didn't know the instructions to create
a button so i recorded a macro that did what i wanted then looked at
the generated code. The recorded macro gave me this:

ActiveSheet.Buttons.Add(x1,x2,x3,x4)

where x1...x4 are numbers. Does anybody know what these numbers are
for? I can't seem to find it in the help menu.

Thanks
Bill


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
2007 Need macro to auto set option buttons all to "Yes" or "No" Paula Excel Worksheet Functions 1 October 20th 09 08:07 PM
Versatile "adaptive" formulae? (instead of "hard"coded IF tests) MCSmarties[_2_] Excel Discussion (Misc queries) 1 October 5th 07 09:28 PM
Shortcut key for "Paste Options" and "Error Checking" buttons? johndog Excel Discussion (Misc queries) 1 October 6th 06 11:56 AM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Standard "Open" and "Save As" Buttons Paulo de Arruda Borelli[_2_] Excel Programming 2 September 2nd 04 06:59 AM


All times are GMT +1. The time now is 08:33 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"