Hi I am new to excel vb.
I am trying to import some values from one software (STAAD.Pro), to excel. It works for small quantity. But when the no of values are more, means number of items are more, it shows the error Runtime error - 9, subscript out of range.
But for small quantity of numbers it works perfectly.
******
The code I used is given below.
I suspect the problem with array. It may be problem with array stack overflow? Or it may be problem due to not defining delimit or ubound?
I dont know how to use ubound or delimit also.
Could anyone suggest me, how it can be resolved.
******
Please help.............
Private Sub CommandButton1_Click()
Dim objOpenSTAAD As Object
Dim supp_Scount As Long
Dim supp_nodes() As Long
Dim loadcase As Long
Dim loadcase1 As Long
Dim loadcase2 As Long
Dim Noloadcase As Long
Dim dReactionArray(0 To 10) As Double
Dim Scount As Long
Dim Scount1 As Long
Dim LCScount As Long
'Dim strstring
''strstring = "Ubound of arrdReactionArray is :" & UBound(arrdReactionArray)
'MsgBox strstring
' opening staad file
Set objOpenSTAAD = GetObject(, "StaadPrpenSTAAD")
' first load case
loadcase1 = Cells(4, 14).Value
' second load case
loadcase2 = Cells(5, 14).Value
' no of load cases
Noloadcase = Cells(5, 14).Value - Cells(4, 14).Value + 1
' no of supports from staad file
supp_count = objOpenSTAAD.Support.GetSupportcount
' defining no of support nodes
ReDim supp_nodes(0 To (supp_count - 1)) As Long
' get support nodes
objOpenSTAAD.Support.GetSupportNodes supp_nodes
' 1 to no of supports in staad
' for each load case
' load case
For Scount = 1 To supp_count
Cells(3 + (Scount - 1) * Noloadcase, 1).Value = supp_nodes(Scount - 1)
' For LCScount = 1 To Noloadcase
For loadcase = loadcase1 To loadcase2
Cells(3 + (Scount - 1) * Noloadcase + loadcase - 100, 2).Value = loadcase
For Scount1 = 1 To 6
objOpenSTAAD.Output.GetSupportReactions supp_nodes(Scount - 1 + loadcase - loadcase1), loadcase, dReactionArray
Cells(3 + (Scount - 1) * Noloadcase + loadcase - 100, Scount1 + 2).Value = dReactionArray(Scount1 - 1)
Next
Next
Next
'Next
Set objOpenSTAAD = Nothing
End Sub
I am trying to import some values from one software (STAAD.Pro), to excel. It works for small quantity. But when the no of values are more, means number of items are more, it shows the error Runtime error - 9, subscript out of range.
But for small quantity of numbers it works perfectly.
******
The code I used is given below.
I suspect the problem with array. It may be problem with array stack overflow? Or it may be problem due to not defining delimit or ubound?
I dont know how to use ubound or delimit also.
Could anyone suggest me, how it can be resolved.
******
Please help.............
Private Sub CommandButton1_Click()
Dim objOpenSTAAD As Object
Dim supp_Scount As Long
Dim supp_nodes() As Long
Dim loadcase As Long
Dim loadcase1 As Long
Dim loadcase2 As Long
Dim Noloadcase As Long
Dim dReactionArray(0 To 10) As Double
Dim Scount As Long
Dim Scount1 As Long
Dim LCScount As Long
'Dim strstring
''strstring = "Ubound of arrdReactionArray is :" & UBound(arrdReactionArray)
'MsgBox strstring
' opening staad file
Set objOpenSTAAD = GetObject(, "StaadPrpenSTAAD")
' first load case
loadcase1 = Cells(4, 14).Value
' second load case
loadcase2 = Cells(5, 14).Value
' no of load cases
Noloadcase = Cells(5, 14).Value - Cells(4, 14).Value + 1
' no of supports from staad file
supp_count = objOpenSTAAD.Support.GetSupportcount
' defining no of support nodes
ReDim supp_nodes(0 To (supp_count - 1)) As Long
' get support nodes
objOpenSTAAD.Support.GetSupportNodes supp_nodes
' 1 to no of supports in staad
' for each load case
' load case
For Scount = 1 To supp_count
Cells(3 + (Scount - 1) * Noloadcase, 1).Value = supp_nodes(Scount - 1)
' For LCScount = 1 To Noloadcase
For loadcase = loadcase1 To loadcase2
Cells(3 + (Scount - 1) * Noloadcase + loadcase - 100, 2).Value = loadcase
For Scount1 = 1 To 6
objOpenSTAAD.Output.GetSupportReactions supp_nodes(Scount - 1 + loadcase - loadcase1), loadcase, dReactionArray
Cells(3 + (Scount - 1) * Noloadcase + loadcase - 100, Scount1 + 2).Value = dReactionArray(Scount1 - 1)
Next
Next
Next
'Next
Set objOpenSTAAD = Nothing
End Sub