Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Jun 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Currently Running Sub/Function (Office 97)

    Is there a function that will return the currently running subroutine or function?
    I'm trying to write errors to a log file and would like to know which procedure errored out.

    Like So:

    Global strCurrProc as String

    Sub DoSomeThing()

    strCurrProc =$Currently_Running_Procedure_Function()

    On Error Goto OOPS
    :
    :
    EXIT_ME:
    Exit Sub

    OOPS:
    WriteLog
    Resume EXIT_ME
    End Sub


    Function WriteToLog()
    Const SYSTEMLOG As String = "K:logsSYSTEM.TXT"
    Dim intFileNum As Integer
    Dim strCurrDate As String
    Dim strCurrTime As String

    intFileNum = FreeFile()
    On Error GoTo WriteLog_Exit
    Open SYSTEMLOG For Append As #intFileNum
    strCurrDate = Format(Date, "mm/mm/yyyy")
    strCurrTime = Format(Time, "hh:nn")
    Print #intFileNum, strCurrDate; Tab; strCurrTime; Tab; strCurrProc

    WriteLog_Exit:
    Close #intFileNum
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Currently Running Sub/Function (Office 97)

    Not that I know of. This has been discussed many times but the simplest way to handle it is to pass the name of the routine back from the error handler explicitly,
    Charlotte

Posting Permissions

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