+ Reply to Thread
Results 1 to 13 of 13

Command Bar - Changing a variable's property?

  1. #1
    Registered User
    Join Date
    08-27-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Command Bar - Changing a variable's property?

    Hi, In my ongoing battle to create this simple add-in for work.

    I've now decided to toggle the reminder on and off using a command button inside a command bar, this is the code I have below.

    Please Login or Register  to view this content.
    Response is a boolean, I've tried all sorts to get this to work and it returns the same error each and every time "Cannot run the macro "pathname". The macro may not be available in this workbook or all macros may be disabled.

    How do you overcome this problem?

    EDIT: Also whilst on the same topic, Is there anyway for me to show some sort of label showing the status of response?
    Last edited by kickme93; 12-05-2013 at 09:06 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: Command Bar - Changing a variable's property?

    Is this: Private Sub App_WorkbookOpen(ByVal Wb As Workbook) meant to be the Workbook Open event. Or do you call it from the Workbook Open event?

    If it's meant to be the Workbook Open event, it isn't. If it is called from the Workbook Open event, it should be in a standard module.

    This worked for me:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-27-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Command Bar - Changing a variable's property?

    I have it in a class module, I was under the impression after Application Events In A New Class Module from this website

    http://www.cpearson.com/Excel/AppEvent.aspx

    that it is meant to be in a class module, am I wrong to assume that?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: Command Bar - Changing a variable's property?

    So, do you dim App and set it in the Workbook Open? I don't think you'd normally need to do that unless you're trapping events out of the norm, like creating a New Workbook.

    In all honesty, I've never needed it ... maybe I'll look for an opportunity to use it but I haven't actually needed it.

    When you try something you think should work and it doesn't, maybe try the thing that you don't think should work but you're told it does


    Regards, TMS

  5. #5
    Registered User
    Join Date
    08-27-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Command Bar - Changing a variable's property?

    Quote Originally Posted by TMShucks View Post
    So, do you dim App and set it in the Workbook Open? I don't think you'd normally need to do that unless you're trapping events out of the norm, like creating a New Workbook.

    In all honesty, I've never needed it ... maybe I'll look for an opportunity to use it but I haven't actually needed it.

    When you try something you think should work and it doesn't, maybe try the thing that you don't think should work but you're told it does


    Regards, TMS
    Just gave that a try, didn't work .

    in this workbook i have the following line of code.

    Please Login or Register  to view this content.
    And that's all really.

    EDIT: I've just tried creating a module and moving the following code into it

    Please Login or Register  to view this content.
    This now makes the menu work, however over functions that are in the class module that rely response now aient working - and It wont let me debug to find out why.

    Please Login or Register  to view this content.
    I have the following public variables declared in the class module..

    Please Login or Register  to view this content.
    Last edited by kickme93; 12-05-2013 at 11:15 AM.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: Command Bar - Changing a variable's property?

    You haven't defined it the way it says on Chip's web site ... but you really don't need it, at least not for this specific task.

    See the attached workbook.

    Regards, TMS
    Attached Files Attached Files

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: Command Bar - Changing a variable's property?

    Please post the workbook.

  8. #8
    Registered User
    Join Date
    08-27-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Command Bar - Changing a variable's property?

    I managed to fix it, After moving the public variables into the module it all came together and worked.

    Thanks for all the help!

    Andy

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: Command Bar - Changing a variable's property?

    You're welcome. Thanks for the rep.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: Command Bar - Changing a variable's property?

    Can I just ask, when you say "I have the following public variables declared in the class module.", what do you mean by that? Which Class module?

  11. #11
    Registered User
    Join Date
    08-27-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Command Bar - Changing a variable's property?

    Quote Originally Posted by TMShucks View Post
    Can I just ask, when you say "I have the following public variables declared in the class module.", what do you mean by that? Which Class module?
    CExcelEvents was the class module that everything was originally in,
    But then I created another module and kept trying the suggestion you put forward earlier. In the end I had this.

    CExcelEvents

    Please Login or Register  to view this content.
    module1

    Please Login or Register  to view this content.
    Now I've got a few other things to program into it however the concept is working. !

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: Command Bar - Changing a variable's property?

    Thanks for sharing your final code. I must have a play with this! Looks like hours of fun

    So, you really DID mean a Class module.

    Regards, TMS

  13. #13
    Registered User
    Join Date
    08-27-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    39

    Re: Command Bar - Changing a variable's property?

    Quote Originally Posted by TMShucks View Post
    Thanks for sharing your final code. I must have a play with this! Looks like hours of fun

    So, you really DID mean a Class module.

    Regards, TMS
    Yes, the top layer of code goes in the class module.
    The second layer of code is in a module

+ 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. Command Button Property
    By BS Singh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-05-2013, 06:28 PM
  2. [SOLVED] Use variable property name
    By konfis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-15-2012, 06:20 AM
  3. [SOLVED] Changing ODBC command texts and refreshing via command button
    By milty456 in forum Excel General
    Replies: 2
    Last Post: 10-09-2012, 12:06 PM
  4. Question about a command or object property
    By ChromiumAgeCollector in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-31-2012, 01:52 PM
  5. ado command timeout property
    By Loane Sharp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2005, 06:05 AM

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