Dear All,
Please help me in my VBA Code. I am getting an error message as Active X can't Create object.
It is a very useful file to me and I needed this in very urgent,
I am pasting my code over here below. Please let me know the mistake I am doing and help me in correcting the code.
Sub GetSteelDesignResults2()
'Declare OpenSTAAD object variable.
Dim objOpenSTAAD As Object
Dim strFileName As String
Dim bIncludePath As Boolean
Dim pnCriticalLC As Integer
Dim pdCritRatio As Double
Dim pdCritSection As Double
Dim pdAllowStresses(7) As Double
Dim lpszCritcCond As String
Dim lpszDESIGNCode As String
Dim pdForces(5) As Double
Dim pdKlr As Double
Dim lpszStatus As String
Dim memb As Long
'Dim memb1 As Integer
Dim lBeamSectionName As String
Dim nMembCount As Long
'Run an instance of OpenSTAAD and open STAAD file
Set objOpenSTAAD = GetObject(, "StaadPro.OpenSTAAD")
bIncludePath = True
objOpenSTAAD.GetSTAADFile strFileName, bIncludePath
Set objOpenSTAAD = CreateObject("OpenSTAAD.Output.1") --------(error place).
objOpenSTAAD.SelectSTAADFile strFileName
'objOpenSTAAD.SelectSTAADFile "D:\RRVUNL STAAD\STAAD FILES\STATIC\PRIMARY_R0_STATIC_3-4-2013.std"
'Declare variables for storing the function results.
'objOpenSTAAD.GetMembersCount = nMembCount
nMembCount = 4598
Worksheets("DESIGNSHEET").Activate
For I = 3 To (nMembCount + 2)
'I = 16
memb = Worksheets("DESIGNSHEET").Cells(I, 3).Value
'Retrieve the steel DESIGN results for beam 2 and store the results in the
'variables pnCriticalLC, pdCritRatio, pdCritSection, pdAllowStresses,
'lpszCritcCond, lpszDESIGNCode, pdForces, pdKlr, and lpszStatus.
objOpenSTAAD.GetSteelDesignResults2 memb, pnCriticalLC, pdCritRatio, _
pdCritSection, pdAllowStresses(0), lpszCritcCond, lpszDESIGNCode, _
pdForces(0), pdKlr, lpszStatus
'Worksheets("Sheet1").Cells(16 + i, 7) = pdCritRatio
Worksheets("DESIGNSHEET").Cells(I, 19) = pdAllowStresses(0)
Worksheets("DESIGNSHEET").Cells(I, 20) = pdForces(0) * 4.44822
Worksheets("DESIGNSHEET").Cells(I, 21) = pdForces(1) * 4.44822
Worksheets("DESIGNSHEET").Cells(I, 22) = pdForces(2) * 4.44822
Worksheets("DESIGNSHEET").Cells(I, 23) = pdForces(3) * 0.112985
Worksheets("DESIGNSHEET").Cells(I, 24) = pdForces(4) * 0.112985
Worksheets("DESIGNSHEET").Cells(I, 25) = pdForces(5) * 0.112985
'Worksheets("DESIGNSHEET").Cells(i, 32) = pnCriticalLC
'Worksheets("DESIGNSHEET").Cells(i, 33) = pdCritSection
' Worksheets("DESIGNSHEET").Cells(16 + i, 24) = pdKlr
Next I
'Close the STAAD file and release the handles to the OpenSTAAD library.
objOpenSTAAD.CloseSTAADFile
Set objOpenSTAAD = Nothing
End Sub
Please help me ....