+ Reply to Thread
Results 1 to 7 of 7

Application.Caller and Activex problem

  1. #1
    Registered User
    Join Date
    11-16-2012
    Location
    Mos Eisly
    MS-Off Ver
    Excel 2007
    Posts
    39

    Application.Caller and Activex problem

    Hi guys I need your help again,

    I'm creating a sort of Time Sheet, and I need to have for each day per Month a Toggle Button on the sheet. (actually they are 7 buttons for each day).
    So I created in Total 217 Buttons, it took me some time to order and resize them and of course to give each one an own name.
    I created them as an ActiveX element as I couldn't see in the Form Controls a ToggleButton.

    Anyway everything is finish now.
    Now I need that each Button do more or less the same except that they write a value in 7 cell in each row (so every button have it's own cell)
    I created a module which do the job, but now I don't want to fill the Page code for the specific sheet with 217 Subs for each button

    is there a way to have like one sub for all buttons?? or a least one sub for each category of button?
    (again I have 7 Buttons: 1x Holidays, 1xVacation, 1xCompany Business, 1x Regular Day Off, 1xSickness, 1xUnpaid and 1xOther)

    I want to be able to click for each day if needed one of these option. and at the end of the month I'll have a calculation of the nbr of days of those 7 categories)

    If there is no possibility to have one Sub for all buttons or one sub for each category, is there a possibility to get the name of the clicked button, so i can call one module at least?? Unfortunately Application.Caller doesn't work with activex elements.

    I hope you didn't got confuse. I have attached my File so far, please ignore the "Summary" sheet and the "Configuration" Sheet. Just the "Jan" sheet.


    thanks alot
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Application.Caller and Activex problem

    Hello Aranell,

    Wow, 217 controls is lot. The way to handle this issue is by Sub-Classing each group of buttons. This will allow them to respond to events and call the same event code. It's the VBA equivalent of a VB Control Array.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Application.Caller and Activex problem

    What does clicking each button actually do?

    As far as I can tell it justs changes the caption and backcolor of the button, is that right?

    Have you considered another approach, perhaps something using the BeforeDoubleClick event?
    If posting code please use code tags, see here.

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

    Re: Application.Caller and Activex problem

    Hi Aranell,

    The following code may help you capture your Active X Toggle Button Events. See the attached working file which uses only 4 Toggle Buttons. Code concepts are courtesy of Andy Pope. Thank you Andy.

    In Class Module ClassToggleButtonEvent:
    Please Login or Register  to view this content.
    In an ordinary Code Module:
    Please Login or Register  to view this content.
    Please note that I have found 'Active X' to be an inferior solution in most applications, because 'Active X' tends to be unstable and can lead to catastrophic file failure. When I use 'Active X', I always create the controls programmatically during software development (as per the example file), in order to make recovery from an 'Active X' disaster less traumatic.

    Lewis
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-16-2012
    Location
    Mos Eisly
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Application.Caller and Activex problem

    First thank you all for help, didn't tray the solution yet.
    @Leith Ross I tried that but couldn't manage it to work
    @Norie: beside changing the backcolor, it also insert a value "1" in a cell when button.value is True, and a "0.5" when the value is False and nothing "" when value is 0.
    I need it to calculate the summary of vacation days for example
    @LJMetzger thanks alot it's working first it didn't as i wanted but then i changed the Class from myToggleButton_Click() to
    myToggleButton_change()
    referring to ActiveX.. I couldn't find an Toggle button on the Form Controls, at least not for direct button on the sheet it self.

    Beside all this, I couldn't find a better solution than the buttons, to mark the day or 1/2 that day as one of these 7 category mentioned in my first post. I could have made it by inserting like 1 or 2 in a certain cell, but i need it to be by clicking and not by writing something.
    Last edited by Aranell; 04-23-2015 at 03:58 AM.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Application.Caller and Activex problem

    All of which could be done using the sheet's BeforeDoubleClick event.

  7. #7
    Registered User
    Join Date
    11-16-2012
    Location
    Mos Eisly
    MS-Off Ver
    Excel 2007
    Posts
    39

    Re: Application.Caller and Activex problem

    can you explain more.. how can i do that

+ 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. [SOLVED] Using Application.caller with Shapes
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2014, 05:07 AM
  2. Application.Caller problem in Excel 2007
    By Moph in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2010, 06:29 AM
  3. [SOLVED] application caller
    By Rich in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2006, 07:35 AM
  4. [SOLVED] Application.Caller
    By Marcelo in forum Excel General
    Replies: 6
    Last Post: 06-23-2006, 10:10 AM
  5. Row = Application.Caller.Row
    By Charles Woll in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-28-2005, 10:06 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