+ Reply to Thread
Results 1 to 7 of 7

Pass Commandbar.Control.caption to sub routine

  1. #1
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Question Pass Commandbar.Control.caption to sub routine

    Hi All,

    I have a custom Commandbar addin with lots of my own macros built in.

    I'm trying to pass a value to a routine and then action it but i can't sus it out.

    here's the commandbar code (this works fine, but i would love to know how to pass the caption of the selected button instead of having to type "vbUpperCase")

    Please Login or Register  to view this content.
    So basically when i click on the "vbUppercase" button it runs the following (but doesn't work )


    Please Login or Register  to view this content.
    any help is really appreciated

    thanks for taking the time to read it
    Last edited by Macdave_19; 07-01-2010 at 10:50 AM.
    Mr MaGoo
    Magoo.Inc MMVII

    If i've helped please add to my Rep by Clicking on the Blue Scales in the top right hand corner of the post

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,987

    Re: Pass Commandbar.Control.caption to sub routine

    StrConv does not take a string as the type argument, it takes an integer value (usually an enum, but you cannot pass the name of the enum value as a string)
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Pass Commandbar.Control.caption to sub routine

    Couple of things, vbUpperCase is a numeric constant rather than a text value.
    Your argument is the same name as the function, StrConv.

    You can pass an argument on the OnAction

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    But I think it would be better to use the Parameter property.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    You could also use the ActionControl object to get the caption

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Thumbs up Re: Pass Commandbar.Control.caption to sub routine

    Romper:

    Cheers mate appreciate the info strange that it doesn't accept a string even though it's has a preficf of STR? pah i dunno lol.

    Pope:
    That worked a frickin treat mate appreciate it

    thanks to both of you

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,987

    Re: Pass Commandbar.Control.caption to sub routine

    StrConv = String Conversion
    nothing to do with the type of argument it takes!

  6. #6
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Thumbs up Re: Pass Commandbar.Control.caption to sub routine

    romper:

    i can work out what the abbreviation means lol, but fair enough i get what your saying. ta mate

  7. #7
    Valued Forum Contributor Macdave_19's Avatar
    Join Date
    03-14-2007
    Location
    Birmingham, England
    MS-Off Ver
    12.0
    Posts
    808

    Re: Pass Commandbar.Control.caption to sub routine

    FYI i gave Romper some +ve feedback but it wouldn't let me add to your andy

+ 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