Dim swApp As Object
Sub main()
Dim swModel As ModelDoc2
Dim swdraw As DrawingDoc
Dim tab1 As TableAnnotation
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swdraw = swModel
Set tab1 = swdraw.SelectionManager.GetSelectedObject6(1, 0)
SetColumnWith tab1
End Sub
Sub SetColumnWith(swTable As TableAnnotation)
Dim index As Integer
Dim swAnnotation As Annotation
Dim swDislplayData As DisplayData
'Dim TextWidth As Double
Set swAnnotation = swTable.GetAnnotation
Set swDislplayData = swAnnotation.GetDisplayData
For i = 0 To swTable.ColumnCount - 1
Dim ColumnWidth As Double
ColumnWidth = swTable.GetColumnWidth(i)
Debug.Print i & ":" & ColumnWidth * 1000
If i = 1 Then
'bRet = swTable.SetColumnWidth (i)
Dim ColWd As Double
ColWd = swTable.GetColumnWidth(i)
Debug.Print ColWd
retHt = swTable.SetColumnWidth(i, 0.0135, 0)
End If
Next
End Sub
This modifies my column well or I have the problem of width and different font.
There is only point 3-) left to change this font.
Option 1 modify it in the nomenclature by changing the font of the column (no idea how to do this
or option 2 change the option in tool option/Document Properties/Tables/Nomenclature/Font
If anyone has a solution to achieve one of these 2 possible options.
Thanks @Maclanefor the lead. In the end, as the problem comes from my document template where the font is set to 16 instead of 10, I preferred to make the modification at the document level, even if your solution probably worked too, but seemed less logical to me for my needs.
For those who would be interested, here is the solution chosen:
Dim swDraw As DrawingDoc
Dim swAnnotation As Annotation
Dim UserPref As Integer
Dim UserPrefOption As Integer
Dim swTextFormat As SldWorks.TextFormat
Dim bRet As Boolean
Set swTextFormat = swAnnotation.GetTextFormat(1)
swTextFormat.CharHeightInPts = "10"
swTextFormat.TypeFaceName = "Arial"
swTextFormat.Bold = False
swTextFormat.Italic = False
bRet = swDraw.Extension.SetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingBillOfMaterialTextFormat, swDetailingBillOfMaterial, swTextFormat)