Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Hide a command button

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Hide a command button

Hi,

Have a look here

http://www.rondebruin.nl/controlsobjectsworksheet.htm

Mike

"jswalsh33" wrote:

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Hide a command button

hi
try something like this
Sub test()
Dim Button_Name As String
Button_Name = "Edit"
If ActiveSheet.Shapes(Button_Name).Visible = True Then
ActiveSheet.Shapes(Button_Name).Visible = False
Else
ActiveSheet.Shapes(Button_Name).Visible = True
End If
End Sub

regards
FSt1

"jswalsh33" wrote:

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Hide a command button



"FSt1" wrote:

hi
try something like this
Sub test()
Dim Button_Name As String
Button_Name = "Edit"
If ActiveSheet.Shapes(Button_Name).Visible = True Then
ActiveSheet.Shapes(Button_Name).Visible = False
Else
ActiveSheet.Shapes(Button_Name).Visible = True
End If
End Sub

regards
FSt1

"jswalsh33" wrote:

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh


Thanks for your response.

When I try this I get the error message: "The item with the specified name
wasn't found."

Jim Walsh
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Hide a command button

hi
is your button named "Edit" or is that just the caption on the button. the
code is looking for a name nor a caption.

Regards
FSt1

"jswalsh33" wrote:



"FSt1" wrote:

hi
try something like this
Sub test()
Dim Button_Name As String
Button_Name = "Edit"
If ActiveSheet.Shapes(Button_Name).Visible = True Then
ActiveSheet.Shapes(Button_Name).Visible = False
Else
ActiveSheet.Shapes(Button_Name).Visible = True
End If
End Sub

regards
FSt1

"jswalsh33" wrote:

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh


Thanks for your response.

When I try this I get the error message: "The item with the specified name
wasn't found."

Jim Walsh



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Hide a command button

There are two very similar buttons that you can place on a worksheet.

One is a button from the Forms toolbar and your code is almost perfect:

Drop the "with" to give this statement:
ActiveSheet.Buttons(Button_Name).Visble = False



The other is a commandbutton from the Control toolbox toolbar.

You should be able to use:
ActiveSheet.OLEObjects(Button_Name).Visible = False

jswalsh33 wrote:

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Hide a command button

ps. Make sure you spell .visible correctly!

ActiveSheet.Buttons(Button_Name).Visible = False
(added an i)

Dave Peterson wrote:

There are two very similar buttons that you can place on a worksheet.

One is a button from the Forms toolbar and your code is almost perfect:

Drop the "with" to give this statement:
ActiveSheet.Buttons(Button_Name).Visble = False

The other is a commandbutton from the Control toolbox toolbar.

You should be able to use:
ActiveSheet.OLEObjects(Button_Name).Visible = False

jswalsh33 wrote:

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh


--

Dave Peterson


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Hide a command button



"Dave Peterson" wrote:

ps. Make sure you spell .visible correctly!

ActiveSheet.Buttons(Button_Name).Visible = False
(added an i)

Dave Peterson wrote:

There are two very similar buttons that you can place on a worksheet.

One is a button from the Forms toolbar and your code is almost perfect:

Drop the "with" to give this statement:
ActiveSheet.Buttons(Button_Name).Visble = False

The other is a commandbutton from the Control toolbox toolbar.

You should be able to use:
ActiveSheet.OLEObjects(Button_Name).Visible = False

jswalsh33 wrote:

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh


--

Dave Peterson


--

Dave Peterson

Dave,

Thanks for you help.

I am using a command button from the Controls Toolbox.

When I use the code: ActiveSheet.OLEObjects(Button_Name).Visible = False I
get an error message "Unable to get the OLE Objects property of the worksheet
class."

Maybe the name I am using, "Edit" is not the name of the button. "Edit" is
what I typed in on the button face. If that is not the name, where do I find
the name of the button?

Regards,

Jim Walsh
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Hide a command button

Go into design mode (another icon on that control toolbox toolbar)
Rightclick on the commandbutton to select it.
Look at the namebox (to the left of the formula bar)
Make a note of that name.
Exit design mode (click that button again)

And change the code and test it.

jswalsh33 wrote:

"Dave Peterson" wrote:

ps. Make sure you spell .visible correctly!

ActiveSheet.Buttons(Button_Name).Visible = False
(added an i)

Dave Peterson wrote:

There are two very similar buttons that you can place on a worksheet.

One is a button from the Forms toolbar and your code is almost perfect:

Drop the "with" to give this statement:
ActiveSheet.Buttons(Button_Name).Visble = False

The other is a commandbutton from the Control toolbox toolbar.

You should be able to use:
ActiveSheet.OLEObjects(Button_Name).Visible = False

jswalsh33 wrote:

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh

--

Dave Peterson


--

Dave Peterson

Dave,

Thanks for you help.

I am using a command button from the Controls Toolbox.

When I use the code: ActiveSheet.OLEObjects(Button_Name).Visible = False I
get an error message "Unable to get the OLE Objects property of the worksheet
class."

Maybe the name I am using, "Edit" is not the name of the button. "Edit" is
what I typed in on the button face. If that is not the name, where do I find
the name of the button?

Regards,

Jim Walsh


--

Dave Peterson
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Hide a command button



"Dave Peterson" wrote:

Go into design mode (another icon on that control toolbox toolbar)
Rightclick on the commandbutton to select it.
Look at the namebox (to the left of the formula bar)
Make a note of that name.
Exit design mode (click that button again)

And change the code and test it.

jswalsh33 wrote:

"Dave Peterson" wrote:

ps. Make sure you spell .visible correctly!

ActiveSheet.Buttons(Button_Name).Visible = False
(added an i)

Dave Peterson wrote:

There are two very similar buttons that you can place on a worksheet.

One is a button from the Forms toolbar and your code is almost perfect:

Drop the "with" to give this statement:
ActiveSheet.Buttons(Button_Name).Visble = False

The other is a commandbutton from the Control toolbox toolbar.

You should be able to use:
ActiveSheet.OLEObjects(Button_Name).Visible = False

jswalsh33 wrote:

I have a worksheet with command buttons on it. I would like to hide one or
more of these buttons depending on circumstances.

I have tried the code:
Dim Button_Name As String
Button_Name = "Edit"
With ActiveSheet.Buttons(Button_Name).Visble = False

the code is included in a macro that activates the worksheet in question.

When I run this I get an error message: "Unable to get button properties of
the worksheet class"

I am running Excel 2003.

Help?

Thanks

Jim Walsh

--

Dave Peterson

--

Dave Peterson

Dave,

Thanks for you help.

I am using a command button from the Controls Toolbox.

When I use the code: ActiveSheet.OLEObjects(Button_Name).Visible = False I
get an error message "Unable to get the OLE Objects property of the worksheet
class."

Maybe the name I am using, "Edit" is not the name of the button. "Edit" is
what I typed in on the button face. If that is not the name, where do I find
the name of the button?

Regards,

Jim Walsh


--

Dave Peterson

Thanks Dave,

The name was the problem.

Jim Walsh


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
Hide Command button - still use it Madiya Excel Programming 6 March 8th 08 02:27 PM
Hide Command button on close Tammy H Excel Programming 1 October 18th 07 11:49 PM
Hide command button MarcoR Excel Programming 2 May 12th 06 05:31 PM
how do you hide a forms command button Paul James[_3_] Excel Programming 4 September 5th 03 06:18 PM
Hide command button on worksheet Mohair Excel Programming 3 July 14th 03 11:06 PM


All times are GMT +1. The time now is 11:25 AM.

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"