Open and Run Arena with VBA Excel

304 Views Asked by At

I am working on a project with the aim to open and run Arena model automatically using VBA from Excel. I used the code introduced here by meat_you. However, currently I am struggling to open and run Arena. While running the code, it opens Arena only without the model file and Excel automatically turns off right away. I have activated all Arena V16 Library in VBA and still the problem happens. I tested it on other computers, some work and some have the same problem, so I guess the problem is not with the code. How would I fix the problem? FYI I used Arena V16 in Student version. My current code:

Sub ARENA_EXECUTE()
'Declare variables
Dim oArenaApp As Arena.Application
Dim oModel As Arena.Model, oSIMAN As Arena.SIMAN
Dim oModule As Arena.Module

'Start Arena, open model, make Arena active & visible
Set oArenaApp = CreateObject("Arena.Application")
ModName = "D:\Model2.doe"
Set oModel = oArenaApp.Models.Open(ModName)
Set oSIMAN = oModel.SIMAN
oArenaApp.Activate
oArenaApp.Visible = True

'Run model in batch mode and send results back to Excel
oModel.BatchMode = True ' Turn off animation
oModel.QuietMode = True ' Do not ask final question
oModel.Go (smGoWait) ' Suspend VB until run ends

'End model run and exit Arena
oModel.End
oArenaApp.Visible = False
End Sub
0

There are 0 best solutions below