Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    Got an observation that's puzzling me - looking for an explanation...

    I'm in the middle of writing an add-in that handles connections etc. to a DB-layer.
    Main part of my code is encapsulated into a class module 'clsDB'.

    To have the functions visible from outside the ad-in, I've added a 'module-layer' with 'public subs', s that calls to the clsDB goes through the module layer,

    ...but - if I'm not passing parameters to the sub - it is visible in 'Tools' -> 'Macro' -> 'Macros' (example below)

    Public Sub GetShareHolders()
    Dim oDB As clsDB
    Set oDB = New clsDB
    oDB.Connect
    oDB.GetMajorShareholders oDB
    Set oDB = Nothing
    End Sub

    ...and - if I do pass parameters - it is no longer visible... - wondering why???

    Public Sub GetShareHolders(ByVal strSource As String, ByVal strTicker As String)
    Dim oDB As clsDB
    Set oDB = New clsDB
    oDB.Connect
    oDB.GetMajorShareholders oDB, strSource, strTicker
    Set oDB = Nothing
    End Sub
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    A macro by definition is a public procedure (sub) without arguments in a standard module.

    It wouldn't make sense to list procedures that have arguments in Tools | Macro | Macros because they can't be run by themselves - you have to specify the argument(s) in order to run them.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Hans,

    Thanks - hadn't thought of that angle.

    It makes sense.
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    You can, incidentally, still run the macros from the dialog, you just have to manually type in the name and parameters.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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