+ Reply to Thread
Results 1 to 6 of 6

Conditionally Hide or deactivate code in an activeX command Button.

  1. #1
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Conditionally Hide or deactivate code in an activeX command Button.

    I have a workbook with multiple sheets, the sheets will be labels 18.08.14 , 25.08.14 etc.

    I have an activex Command button that will once pressed run code to send a section of the sheet as an email to a group of people. I need to disable this button when we're no longer in this period. i.e. if todays date is greater greater than 7 days from the sheet name either disable or hide the button.

    Thank you for any advice or help, in advance.
    Last edited by Kramxel; 08-26-2014 at 07:36 AM.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Conditionally Hide or deactivate code in an activeX command Button.

    Hi Kramxel,

    Try the attached workbook (tested using Excel 2003). Please note that I have had problems in the past moving ActiveX controls between Excel Versions. If the sample workbook doesn't work, please delete the Active X Buttons and replace them with new Active X 'CommandButton1' and 'CommandButton2' before giving up and thinking that the code doesn't work.

    ThisWorkbook Code:
    Please Login or Register  to view this content.
    Sheet Code (on every sheet):
    Please Login or Register  to view this content.
    Ordinary Module Code (e.g. Module1):
    Please Login or Register  to view this content.
    Lewis

  3. #3
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Re: Conditionally Hide or deactivate code in an activeX command Button.

    Hi,

    Thank you for this.

    I think I've got it working, however for some reason Sheets(1).Select on the open workbook sub is throwing an error (run-time error 1004, application-defined or object-defined error), if i change it it sheets(2).select it works fine.
    Last edited by Kramxel; 08-26-2014 at 08:57 AM. Reason: I was being an idiot.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Conditionally Hide or deactivate code in an activeX command Button.

    It's a known feature (which I just discovered) that Excel occasionally behaves in the manner you described (Runtime Error 1004 for a select or activate) during 'Workbook_Open().

    Try the attached file which implements the following changes:

    ThisWorkbook Module:
    Please Login or Register  to view this content.
    Ordinary Code Module (the following was added):
    Please Login or Register  to view this content.
    Lewis

  5. #5
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Re: Conditionally Hide or deactivate code in an activeX command Button.

    Bizarre this didn't solve the problem either exact same problem (but when I call the sheet by name works fine)

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Conditionally Hide or deactivate code in an activeX command Button.

    Thanks for the feedback. I'll make a note that the problem still exists for future reference.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 06-18-2014, 02:25 PM
  2. Hide or deactivate a ribbon button
    By Zer0aim in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2013, 05:51 AM
  3. Run activex command button via macro
    By dhaval123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2013, 06:07 AM
  4. ActiveX Command Button Text Looks Bad
    By brownsl in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-07-2012, 07:35 AM
  5. ActiveX command button
    By Dr.Schwartz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2005, 04:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1