0% found this document useful (0 votes)
28 views5 pages

Job Information Retrieval Script

The document is a VBA subroutine that retrieves job information from STAAD.Pro using OpenSTAAD. It creates or clears a worksheet named 'JobInfo', collects various job details, and logs them into the worksheet. Additionally, it applies XLOOKUP formulas for base unit and status descriptions, and retrieves file path and unit information for the currently open .STD file.

Uploaded by

pushp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

Job Information Retrieval Script

The document is a VBA subroutine that retrieves job information from STAAD.Pro using OpenSTAAD. It creates or clears a worksheet named 'JobInfo', collects various job details, and logs them into the worksheet. Additionally, it applies XLOOKUP formulas for base unit and status descriptions, and retrieves file path and unit information for the currently open .STD file.

Uploaded by

pushp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Sub Get_Job_Info()

On Error GoTo ErrorHandler

Call [Link]("Getting Job Info")

' Get the application object

Dim objOpenSTAAD As Object

Set objOpenSTAAD = GetObject(, "[Link]")

If objOpenSTAAD Is Nothing Then

MsgBox "[Link] is not running or OpenSTAAD is unavailable.", vbCritical

Exit Sub

End If

' Create or clear the "JobInfo" sheet

Dim ws As Worksheet

On Error Resume Next

Set ws = Worksheets("JobInfo")

On Error GoTo 0

If ws Is Nothing Then

Set ws = [Link](After:=ActiveSheet)

[Link] = "JobInfo"

Else

' Clear all contents

[Link]
' Reset outline levels

[Link] RowLevels:=1, ColumnLevels:=1

End If

' Get Job Info

Dim jobName As String, jobClient As String, enggName As String, eDate As String

Dim jobNumber As String, revision As String, part As String, reference As String

Dim checkerName As String, chDate As String, approverName As String, aDate As


String

Dim comments As String, statusDescription As String

[Link] jobName, jobClient, enggName, eDate, jobNumber,


revision, part, reference, checkerName, chDate, approverName, aDate, comments

' Get Base Unit Info

Dim BaseUnitNo As Long

BaseUnitNo = [Link]()

'Retrieve the entire path

Dim fileName As String

Dim bFullPath As Boolean

bFullPath = True

[Link] fileName, bFullPath

' Get Analysis Info

Dim NoOfWarnings As Long, NoOfErrors As Long

Dim CPUTime As Double, AnalysisStatus As Long

AnalysisStatus = [Link](fileName, NoOfWarnings,


NoOfErrors, CPUTime)
' Prepare log data

Dim logData(1 To 20, 1 To 2) As Variant

logData(1, 1) = "Job Name": logData(1, 2) = jobName

logData(2, 1) = "Client": logData(2, 2) = jobClient

logData(3, 1) = "Engineer": logData(3, 2) = enggName

logData(4, 1) = "Engineer Date": logData(4, 2) = eDate

logData(5, 1) = "Job Number": logData(5, 2) = jobNumber

logData(6, 1) = "Revision": logData(6, 2) = revision

logData(7, 1) = "Part": logData(7, 2) = part

logData(8, 1) = "Reference": logData(8, 2) = reference

logData(9, 1) = "Checker": logData(9, 2) = checkerName

logData(10, 1) = "Checker Date": logData(10, 2) = chDate

logData(11, 1) = "Approver": logData(11, 2) = approverName

logData(12, 1) = "Approval Date": logData(12, 2) = aDate

logData(13, 1) = "Comments": logData(13, 2) = comments

logData(14, 1) = "Base Unit No": logData(14, 2) = BaseUnitNo

logData(15, 1) = "AnalysisStatus": logData(15, 2) = AnalysisStatus

logData(16, 1) = "Status Description": logData(16, 2) = statusDescription

logData(17, 1) = "Warnings": logData(17, 2) = NoOfWarnings

logData(18, 1) = "Errors": logData(18, 2) = NoOfErrors

logData(19, 1) = "CPU Time (s)": logData(19, 2) = Round(CPUTime, 2)

logData(20, 1) = "Retrieved On": logData(20, 2) = Format(Now, "yyyy-mm-dd


hh:nn:ss")

' Write headers and results

[Link]("A1:B1").Value = Array("Parameter", "Value")


[Link]("A2:B21").Value = logData

[Link]("A:B").AutoFit

[Link]("A1:B1").[Link] = True

' Apply XLOOKUP for Base Unit Description

Dim formulaRange As Range

Set formulaRange = [Link]("C15")

formulaRange.FormulaR1C1 = "=XLOOKUP(RC[-
1],'STAAD_SECTION_TYPE_TABLE'!R17C10:R18C10,'STAAD_SECTION_TYPE_TABLE'!R17
C11:R18C11,""NA"",0)"

' Apply XLOOKUP for Status Description

Dim formulaRange1 As Range

Set formulaRange1 = [Link]("B17")

formulaRange1.FormulaR1C1 = "=XLOOKUP(R[-
1]C,'STAAD_SECTION_TYPE_TABLE'!R21C10:R28C10,'STAAD_SECTION_TYPE_TABLE'!R2
1C11:R28C11,""NA"",0)"

'Get file path

[Link]("D2").Value = "File Path"

[Link]("E2").Value = fileName

'Input unit of force and Length of the currently open .STD file.

Dim ForceUnit As String

Dim LengthUnit As String

[Link] ForceUnit

[Link] LengthUnit

[Link]("D3").Value = "Force Unit"

[Link]("E3").Value = ForceUnit
[Link]("D4").Value = "Length Unit"

[Link]("E4").Value = LengthUnit

'Autofit columns

[Link]("A:E").AutoFit

Call [Link]("Job information retrieved and logged successfully.")

[Link] = False

Exit Sub

ErrorHandler:

MsgBox "An error occurred: " & [Link], vbCritical

[Link] = False

End Sub

You might also like