The procedure for requesting AWR support has changed. Please read all about the new AWR product support process.
Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You will first have to enable scripts in Excel. To do this, open up Excel, select Tools > Macros > Security and set it to medium. Open up Excel, go to Tools > Macros > Visual Basic Editor and create a new code module

Code Snippets

...

Code Block
languagevb
 Sub MWO01()
'note the name of the application to create the object came from
'running the registry editor "regedit" and looking under "HKEY_CLASSES_ROOT"
'for the "AWR.MWOffice" objects

On Error GoTo Catch

'uncomment the line for the proper version of AWR.
Set MWOffice2 = CreateObject("AWR.MWOffice.8.0")

MWOffice2.Open ("C:\Documents and Settings\ryan\My Documents\AWR\Scripts\batch\test1.emp")
MWOffice2.Project.simulate
MWOffice2.Project.Save
'MWOffice2.Project.Close
MWOffice2.Open ("C:\Documents and Settings\ryan\My Documents\AWR\Scripts\batch\test2.emp")
MWOffice2.Project.simulate
MWOffice2.Project.Save
'MWOffice2.Project.Close
MWOffice2.Open ("C:\Documents and Settings\ryan\My Documents\AWR\Scripts\batch\test3.emp")
MWOffice2.Project.simulate
MWOffice2.Project.Save
'MWOffice2.Project.Close
MWOffice2.Open ("C:\Documents and Settings\ryan\My Documents\AWR\Scripts\batch\test4.emp")
MWOffice2.Project.simulate
MWOffice2.Project.Save
'MWOffice2.Project.Close
MWOffice2.Open ("C:\Documents and Settings\ryan\My Documents\AWR\Scripts\batch\test5.emp")
MWOffice2.Project.simulate
MWOffice2.Project.Save
MWOffice2.Project.Close


Catch:
'MsgBox Err.Number & vbCrLf & Err.Description
    If Err.Number = 851 Then 'if not dirty will skip save command
        Resume Next
    Else
       'MsgBox Err.Number & vbCrLf & Err.Description
    End If
    
End Sub

 

 

Powershell as batch controller

A powershell batch file to load a project, simulate it and save it would look like:

...

Code Block
languagepowershell
 $mwo = new-object -comobject "AWR.MWOffice"
sleep(5)
$mwo.Open($input_file)
$mwo.Project.Simulate()
$mwo.Project.SaveAs($output_file)
$mwo.Project.Close()
$mwo.Quit()


Assuming the variables $input_file and $output_file have been previously defined.

...