I was wondering if the Object model allows a macro to be written to grab the object names and definitions used on the current report and export them to a flat file.
Can someone point me in the right direction please?
Thanks.
Hao.
Is there any way in VBA to determine whether a report variable or formuls is Character, numeric, od date ?? I’ve been digging most of the day without success.
I can tell you if it is a dimension, detail, or measure (variable.Qualification), whether it is a variable or formula (does variable.Name have a value), whether it comes from a data provider or is a report (local) variable (variable.IsDataProviderObject), but strangely enough, there is no option to determine the datatype.
You could check one of the values using the various Is{SomeType} functions. I don’t know how reliable it would be. Here’s some sample code I tossed together to test this. Note at the end the data type is inferred from the first value from each variable…
Sub ListVariables()
Dim boDocument As busobj.Document
Dim boDocVar As busobj.DocumentVariable
Dim i, intVariableCount As Integer
Dim strItemType, strItemName, strDataType As String
Set boDocument = ActiveDocument
intVariableCount = boDocument.DocumentVariables.Count
For i = 1 To intVariableCount
Set boDocVar = boDocument.DocumentVariables.Item(i)
If boDocVar.Name = "" Then
strItemType = "Formula"
Else
strItemType = "Variable"
End If
strItemName = boDocVar.Name
variantTmpValue = boDocVar.Values(boUniqueValues)
If IsNumeric(variantTmpValue(1)) Then
strDataType = " is numeric"
Else
If IsDate(variantTmpValue(1)) Then
strDataType = " is date"
Else
strDataType = " is character"
End If
End If
If strItemType <> "Formula" Then
MsgBox "Item " & strItemName & strDataType
End If
Next i
End Sub
Good luck! Post back if you get a better solution.
Awesome.
Unfortunately I’ve got the classic problem of numeric values in character fields with the usual requirement of keeping leading zeros. And those are seen as “numeric”.
I know that the DP variables do have a Type so perhaps this is another flaw in the model.
I’ll keep my toes crossed and hope someone else has found a solution.
dave could u please tell what is variantTmpValue declared as
can u please tell whether the code u have posted lists the datatype of report variables and how to find whether its a date,character,Numeric datatype,if possible please paste the code once again