SIMAN errors and VBA

4.4k Views Asked by At

I'm using this code with Arena, a simulation software by Rockwell Automation. I'm trying to get the code to read some data from an excel sheet and assign it to an attribute of the entity which enters the vba module. When I run the simulation, I get this SIMAN error window:

"17035:EEVBA Entity: 2

A runtime error was detected at time 0.0 at the following block: * 6 15$ VBA:0,vba:NEXT(2$);

Event number 0 is invalid: must be positive."

What does that error mean? This is my code, any suggestions? :

Option Explicit
Public XL As Object
Public Wo As Integer
Public W_1 As Integer
Public NumContenedor As Integer

Public Sub ModelLogic_RunBeginSimulation()
    Dim m As Model
    Set m = ThisDocument.Model
    Dim FileToOpen As String
    Set XL = GetObject("", "Excel.Application")
    FileToOpen = "C:\Users\A\data.xlsx"
    XL.Workbooks.Open FileToOpen
End Sub

Public Sub VBA_Block_1_Fire()
    Dim s As SIMAN
    Set s = ThisDocument.Model.SIMAN
    NumContenedor = s.EntityAttribute(s.ActiveEntity, s.SymbolNumber("NumContenedor"))
    Wo = XL.Workbooks(1).Worksheets(1).Cells(NumContenedor, 4).value
    W_1 = XL.Workbooks(1).Worksheets(1).Cells(NumContenedor, 5).value
    s.EntityAttribute(s.ActiveEntity, s.SymbolNumber("deltaW")) = W_1 - Wo
End Sub

Public Sub ModelLogic_RunEnd()
    XL.Quit
End Sub
1

There are 1 best solutions below

0
On BEST ANSWER

The cookie number of my VBA block wasn't matching the number in the procedure name VBA_Block_1_Fire()

duh