Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Nov 2001
    Location
    London
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Procedure Name (97)

    I would like to pass the name of the procedure that I am currently in into a function. I can get the name of the module as follows:
    Application.VBE.SelectedVBComponent.Name

    but is there a way to also get the procedure name?

    Any help much appreciated

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Procedure Name (97)

    Amanda, <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=vb&Number=44218&page=&view= &sb=&o=&vc=1>Here's</A> a thread that may help. It also refers to a related thread. HTH --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    New Lounger
    Join Date
    Nov 2001
    Location
    London
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Procedure Name (97)

    Sammy

    I've had a look at the links but it doesn't seem to give me what I'm looking for.

    The following
    Sub TestProcName()
    Dim ThisProc As String
    Dim xStartLine As Long, XStartColumn As Long, xEndLine As Long, xEndColumn As Long

    With Application.VBE.ActiveCodePane
    .GetSelection xStartLine, XStartColumn, xEndLine, xEndColumn
    With .CodeModule
    ThisProc = .ProcOfLine(xStartLine, 0)
    MsgBox (ThisProc)
    End With
    End With
    End Sub

    simpy tells you where the cursor is in the module

    The rest of the code is for word dialogs

    Thanks anyway

  4. #4
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Procedure Name (97)

    GetSelection just gets the current line which is 1 if the VBE is closed, so I don't think that you can use the VBE object. Also as you pointed out, Dialogs is out because you don't have a Display method in Excel. I think that you just have to add a line of code, Const NAME = "myName", to each proc where myName is the actual name of the proc. If you have lots of procs, you could write a VBE routine to add the lines. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Posting Permissions

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