Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run Sub using Variable (VBA/Powerpoint/2000)

    Hi.

    I'm getting a little confused. Should I be able to run a Sub using a variable.

    i.e.

    Sub SomeThing()
    Call SomethingElse("etc", "MYSUB")
    End Sub


    Function SomethingElse(str1 As String, str2 As String)
    some code = str1
    str2
    End Function

    Hope that sort of makes sense but the str2 is where i want another sub called

    At the moment i get a Complie error: Expected Sub, Function, or Property.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run Sub using Variable (VBA/Powerpoint/2000)

    str2 is a string containing the name of a procedure, not the procedure itself, so you cannot just use

    str2

    Try the following instead:

    Application.Run str2

  3. #3
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run Sub using Variable (VBA/Powerpoint/2000)

    Excellent.

    many thanks Hans.

    i've been stuck all day on that.

Posting Permissions

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