Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Location
    New Zealand
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How can I tell what procedure opened a form? (VBA Word 2k (SP1))

    I want to use one utility form for 2, poss 3 purposes - actually a progress bar as described at the MVP site.

    The code I run in the UserForm_Activate routine is dependent on what procedure calls the form. Is there any way to determine this?

    TIA,
    Kevin M

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: How can I tell what procedure opened a form? (VBA Word 2k (SP1))

    Kevin,

    Here's one way to do it (no doubt there are others):

    I'm assuming your userform is in the same template as the procedures that need to call it.

    In the same template, in any standard code module put code like this:

    <pre>Public strCallProcName As String

    Public Sub SetCallingProcName(strProcName As String)
    strCallProcName = strProcName
    End Sub</pre>

    The calling procedure (we'll assume this one is called "CallingProcedure1"), which wants to show the form, would use code like this:

    <pre>SetCallingProcName "CallingProcedure1"
    frmTest.Show
    </pre>

    And in the UserForm_Activate procedure, you can have code like:

    <pre>Private Sub UserForm_Activate()
    Select Case strCallProcName
    Case "CallingProcedure1"
    'do something
    Case "CallingProcedure2"
    'do something else
    Case Else
    'do another thing
    End Select
    End Sub</pre>

    Gary

Posting Permissions

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