Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
wf wf is offline
external usenet poster
 
Posts: 2
Default Help with Command Button

How to define the properties for a command button so that it works in a
worksheet?

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Help with Command Button

Hi W,

How to define the properties for a command button so that it works in a
worksheet?


Manually?
In design mode, right-click the CommandButton and select
'Properties' from the dropdown menu.

With VBA?

Try, something like:

'=============
Private Sub Worksheet_Activate()
With Me.CommandButton1
.BackColor = &H80000012
.ForeColor = &HFF&
End With
End Sub
'<<=============

This is worksheet event code and should be pasted into
the worksheets's code module (not a standard module
and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.

Alternatively, perhaps, in a standard module:
'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim oleObj As OLEObject

Set WB = Workbooks("MyBook.xls")
Set SH = WB.Sheets("Sheet1")
Set oleObj = SH.OLEObjects("CommandButton1")
With oleObj.Object
.ForeColor = &H80FFFF
.BackColor = &HFF&
End With
End Sub
'<<=============


---
Regards,
Norman



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
VB's Command Button vs Form's Command Button Ronald Dodge Excel Programming 3 May 24th 06 02:23 PM
Command Button vs Form Button Bri[_3_] Excel Programming 2 February 3rd 06 08:18 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 01:51 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"