Consulting

Results 1 to 5 of 5

Thread: Passing Variable with .OnAction

  1. #1
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location

    Passing Variable with .OnAction

    Can someone please advise if there is a way to pass a variable with the .OnAction line? The following does not seem to work.

    [VBA]
    With .Controls.Add(Type:=msoControlButton)
    .Caption = "Auction View"
    .FaceId = 384
    .OnAction = "createView(""auctionView"")"
    .Width = myIconWidth
    [/VBA]

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Presuming that "Auction View" is a string, not tested, try:
    [vba]
    .OnAction = "'createView ""auctionView""'"
    [/vba]
    Please carefully note that there are single quotes on the inner-side of the outermost double-quotes.

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Here is an article by Tushar Mehta:

    http://www.tushar-mehta.com/excel/vb...0arguments.htm

  4. #4
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location
    Quote Originally Posted by GTO
    Presuming that "Auction View" is a string, not tested, try:
    [vba]
    .OnAction = "'createView ""auctionView""'"
    [/vba] Please carefully note that there are single quotes on the inner-side of the outermost double-quotes.
    Thanks. That seems to have done the trick...at last as far as I can tell now. At least it's calling the appropriate subroutine. Still got a problem with functionality in that sub but I think I can tinker with it and get it working right. I'm going to leave this thread open for now just in case I run into a snag.

    Thanks again,

    Opv

  5. #5
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location
    Quote Originally Posted by GTO
    Here is an article by Tushar Mehta:

    http://www.tushar-mehta.com/excel/vb...0arguments.htm
    Thanks.

Posting Permissions

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