Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Hide Command button on close

Hi All,
I have a worksheet that has a command button. When the command button is
clicked it emails the form. I need to hide the command button and the row
where it is located on the form. There are several things that happen when
the command button is selected. Everything works until I get to the send
email part so I have listed the part where I seem to be stuck.

I have tried the following

ActiveSheet.Unprotect
Shapes("CommandButton2").Visible = False
Rows("44:47").Select
Selection.EntireRow.Hidden = False
Rows("34:35").Select
Selection.EntireRow.Hidden = True
Range("B2:C2").Select
ActiveSheet.Protect

ActiveWorkbook.SendMail "***", ActiveSheet.Range("X5").Text

ActiveWorkbook.Close Savechanges:=False

When the command button is clicked it unhides rows 44:47, Selects cell B2:C2,
Protects the sheet, sends the email, closes without saving changes. But it
will not hide the command button or the rows 34:35.

What am I missing?

Any help is appreciated.





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Hide Command button on close

Hi All,
I have a worksheet that has a command button. When the command
button is clicked it emails the form. I need to hide the command
button and the row where it is located on the form. There are
several things that happen when the command button is selected.
Everything works until I get to the send email part so I have listed
the part where I seem to be stuck.

I have tried the following

ActiveSheet.Unprotect
Shapes("CommandButton2").Visible = False
Rows("44:47").Select
Selection.EntireRow.Hidden = False
Rows("34:35").Select
Selection.EntireRow.Hidden = True
Range("B2:C2").Select
ActiveSheet.Protect

ActiveWorkbook.SendMail "***", ActiveSheet.Range("X5").Text

ActiveWorkbook.Close Savechanges:=False

When the command button is clicked it unhides rows 44:47, Selects
cell B2:C2, Protects the sheet, sends the email, closes without
saving changes. But it will not hide the command button or the rows
34:35.

What am I missing?

Any help is appreciated.


Have you tried your code without making unnecessary selections?

ActiveSheet.Unprotect
Shapes("CommandButton2").Visible = False
Rows("44:47").EntireRow.Hidden = False
Rows("34:35").EntireRow.Hidden = True
Range("B2:C2").Select '<============== assume you want to end up with these
cells selected.
ActiveSheet.Protect

ActiveWorkbook.SendMail "***", ActiveSheet.Range("X5").Text
ActiveWorkbook.Close Savechanges:=False

I may be wrong, but is a command button really a member of the Shapes
collection of the active sheet? Was it from the Control Toolbox toolbar or
the Forms toolbar?


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 Close Button Excel 2007 [email protected] Excel Discussion (Misc queries) 0 May 31st 07 07:52 AM
Hide command button MarcoR Excel Programming 2 May 12th 06 05:31 PM
Hide all Excel tool/command bars except mine and reload on close Matt Jensen Excel Programming 2 December 20th 04 05:44 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 05:00 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"