LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Toggle change control button face id & caption


The following code toggles a command button turning on & off an inpu
range. Need VBA code to that would change the face id & caption of th
command button when the input range goes on & toggle back when th
input ranges goes off. Any ideas?

Dim INPUTRANGE
Sub Auto_Open()
'BEGIN INPUTMACROTOGGLE.XLS
'To add a command button
Dim CB As CommandBar
Dim CBB1 As CommandBarButton
Set CB = Application.CommandBars(1)
Set CBB1 = CB.Controls.Add(Type:=msoControlButton, _
befo=CB.Controls.Count, ID:=59, temporary:=True)
With CBB1
.Caption = "Turn on input range"
.FaceId = 352
.Style = msoButtonIconAndCaption
.OnAction = "CursorMovementLimitActivateDeactivate"
End With
End Sub
Sub CursorMovementLimitActivateDeactivate()
'To Activate a limited area of cursor movement & wrap after las
cell
If ActiveSheet.ScrollArea = "" Then
INPUTRANGE = InputBox("Enter input cell range with colo
(ex-A125:D138): ")
If INPUTRANGE = False Then Goto Done
If INPUTRANGE = "" Then Goto Done
Range(INPUTRANGE).Select
'To turn on underline & vertical lines of cells in inpu
range
With Range(INPUTRANGE)
Selection.Borders(xlInsideVertical).LineStyle
xlContinuous
Selection.Borders(xlInsideHorizontal).LineStyle
xlContinuous
End With
'To turn off selection
ActiveCell.Offset(0, 0).Select
'To turn on cursor movement & direction to the right on enter
Application.MoveAfterReturn = True
Application.MoveAfterReturnDirection = xlToRight
'To turn on cursor movement range limits
ActiveSheet.ScrollArea = INPUTRANGE
Else
'To Deactivate a limited of cursor movement
INPUTRANGE = ActiveSheet.ScrollArea
'To turn off underline & vertical lines of cells in inpu
range
Range(INPUTRANGE).Select
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
'To turn off selection
ActiveCell.Offset(0, 0).Select
'To turn off cursor movement range limits
ActiveSheet.ScrollArea = ""
Done:
End If
End Sub
Private Sub Auto_Close()
On Error Resume Next
With Application.CommandBars(1)
.Controls("Input range on/off").Delete
End With
'END INPUTMACROTOGGLE.XLS
End Su

--
mikebur
-----------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458
View this thread: http://www.excelforum.com/showthread.php?threadid=38215

 
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
change the face color of an Excel command button Chris Leah Excel Discussion (Misc queries) 5 April 21st 23 09:03 AM
How to change Button Caption? BrianB Excel Programming 3 June 1st 05 06:24 PM
Place the caption of a toggle button into a cell [email protected] Excel Worksheet Functions 2 May 12th 05 04:47 AM
setting the caption in a button control Andy Dorph Excel Programming 4 December 15th 04 05:03 PM
Toggle custom button caption Tummy Excel Programming 4 February 23rd 04 07:40 PM


All times are GMT +1. The time now is 05:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"