Reporting > Native reporting system > Reporting system command language > FMTSCRPTVBA subcommand
  
FMTSCRPTVBA subcommand
The FMTSCRPTVBA subcommand runs a VBA macro to format a selected value.
Syntax
FIELD name { .. FMTSCRPTVBA "project.module.macro" }
Example VBA script
' you can also have Public Sub TestRptVBA(ByVal v_s_Name As String, ByVal v_s_DDID As String, ByRef r_strResult As Variant)
Public Sub TestRptVBA(ByVal v_s_Name As String, ByVal v_l_DDID As Long, ByRef r_strResult As Variant)
Dim def As Definition
Dim dgm As Diagram
Dim sym As Symbol
Dim bOldRO As Boolean

bOldRO = sa2001.Encyclopedia.OpenObjectsAsReadOnly
sa2001.Encyclopedia.OpenObjectsAsReadOnly = True
Set def = sa2001.Encyclopedia.GetDefinitionById(v_l_DDID)
sa2001.Encyclopedia.OpenObjectsAsReadOnly = bOldRO
If Not def Is Nothing Then
Select Case def.SAClass
Case 1: ' for diagrams..
r_strResult = "Dgm " & def.name

Case 2: ' for saved symbols..
Set dgm = sa2001.Encyclopedia.GetCurrentDiagram
If Not dgm Is Nothing Then
Set sym = dgm.GetSymbolById(v_l_DDID)
If Not sym Is Nothing Then
r_strResult = "Sym " & sym.name
End If
End If

Case 3: ' for definitions
r_strResult = "Def " & def.name
End Select
End If
End Sub

Example report script:
REPORT "TestRptVBA"
ID 49552
{
FONT "Font5" { NAME "Courier" HEIGHT 12 }
SETTING { DECIMALSEPARATOR "." }
SETTING { LISTSEPARATOR "," }
SETTING { MEASUREMENT METRIC }
SETTING { PAGESIZE -1", 0.00 }
SETTING { HEADER 1 "syms defined by" }
SETTING { REPORTFORMAT 20 }
SETTING { OUTPUTFILE "C:\Users\myname\AppData\Local\Telelogic\System Architect\Temporary\sa6894.tmp" }
SETTING { EXTRACT YES EXTRACTFILE "C:\Users\myname\AppData\Local\Telelogic\System Architect\Temporary\sa6894" }
SETTING { STYLESHEETFILE "Reports\Stylesht\HTML Tables.xsl" }
FIELD "Description <-- Description" { SOURCE PROPERTY "Description" LENGTH 4074 TYPE MEMO LEGEND "Description" }
FIELD "formatted" { SOURCE PROPERTY "Name" LENGTH 80 TYPE MEMO fmtscrptvba "Test.Autoexec.TestRptVBA" }
TABULAR 1
{
SELECT "Name" LEGEND "Symbol" LEGENDFONT Font5, "formatted"
WHERE Class = Symbol
WHERE Current = T
WHERE Selected = "T"
ORDERBY "Name"
JOIN
WHERE RELATION = "defined by"
JOIN
SELECT "Name" LEGEND "Definition" LEGENDFONT Font5, "Description <-- Description", "formatted"
WHERE Class = Definition
ORDERBY "Name"
}
}
Parent topic
Reporting system command language