+ Reply to Thread
Results 1 to 4 of 4

Macro Buttons

  1. #1
    Registered User
    Join Date
    11-17-2005
    Location
    Georgia
    Posts
    82

    Macro Buttons

    Good evening..

    Last week I posted a question on how to make multiple buttons point to a common subroutine. Leith Ross posted some code to help me out (thanks Leith) I decided to make a new thread because I had a couple of extra questions...( the original thread is here: http://www.excelforum.com/showthread.php?t=595608 )

    I was on the road at the time and did not have time to test it out. I finally tried it and I was getting and "Object Required" error at

    Please Login or Register  to view this content.
    I received the same error no matter if I placed the code in the sheet object or a separate module.

    I played and tweaked a little and I was able to get something going from his basic structure. The following syntax seems to work:

    Please Login or Register  to view this content.
    The problem with this is that without the "Dim btn as Excel.Button" then you can not access the btn properties (btn.caption, btn.name)

    Any ideas on getting rid of the above error?

    Now for my other question:
    I have read a good bit on the difference between buttons created from the control toolbox vs the forms toolbox... I wish there was a hybrid between the two types...

    Buttons from the control toolbox enable you to set properties such as name etc etc, and I know since they are really an ActiveX control that they also support many more actions than a form button (mouseover, dblclick etc etc) One limitation is that you can not point it to a specific sub like I was trying. I got around this by REMOVING the "=EMBED("Forms.CommandButton.1","") code from the formula bar while in design mode. This makes it so you can not access the properties, but you can point it to a different sub.

    Is there anyway to access properties for a button created using the forms toolbox so I can edit the name? (the button is on a sheet, not an actual form)

    What type of buttons do ya'll Experts use most and why?

    I have attached a small spreadsheet that has working and non working code that shows what I am trying to do (I hope)
    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
    Hello Tekman,

    Application.Caller only works with the Forms menu controls. If your buttons were created using the Control Toolbox it won't work.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    11-17-2005
    Location
    Georgia
    Posts
    82
    Thanks Leith

    I figured that out but the issue that I would like to resolve is the error I am receiving with the following:


    Please Login or Register  to view this content.
    if I just use
    Please Login or Register  to view this content.
    then it works, but I can not access the properties of the button
    The original code that you posted gives me an object required error no matter where I put the code.

    Thanks,

    Lee

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

    Try this code it will only run if called by a Forms command button.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 04-12-2007 at 05:41 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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