Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8166
    ABS
    Participant

    I just got your book and am looking forward to learning all the info inside. To start, I want to use the controller to step through and run various hec models in different folders one after the other. I set a script to do this, and it is close to working, but with one problem.

    The first model runs, but then it is waiting for me to press the “close” button after it completes. (Excel says “Excel is waiting for another application to complete an OLE action”) If I manually press close, the script does continue and runs the next model.

    So, I’d like to add a line to have the script close the model. In the book, there are several examples that use the code:

    ‘Close HEC-RAS
    RC.QuitRAS

    However, when I try this line in my script, it is not recognized. It is also not shown as a command option in the drop down list when I start typing RC… Based on the response to another question, is this command only valid in 5.0 (I am using hec version 4.1.0)? Is there another way to close a model via script? That would be so helpful.

    #13483
    Zain
    Participant

    Hello

    Well i encountered this problem today and in finding a solution on the interent, i came across your query.

    I found a solution and thought of sharing it so that others could benefit from it.

    In excel, paste this in the module:

    Sub test()

    Dim oServ As Object
    Dim cProc As Variant
    Dim oProc As Object

    Set oServ = GetObject(“winmgmts:”)
    Set cProc = oServ.ExecQuery(“Select * from Win32_Process”)

    For Each oProc In cProc

    ‘Rename EXCEL.EXE in the line below with the process that you need to Terminate.
    ‘NOTE: It is ‘case sensitive

    If oProc.Name = “ras.exe” Then
    MsgBox “KILL” ‘ used to display a message for testing pur
    errReturnCode = oProc.Terminate()
    End If
    Next

    End Sub

    This would simply kill the ras process. Delete the msgbox statement and it will become more spontaneous. By doing this, you dont have to end up your procedure and can continue working in the same subroutine .

    Hope it helps.

    Regards
    Nayyar

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.