Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Can some one give me macro code , For changing label Name in Table Box.
Sathish
Sub TableBox
set tb = ActiveDocument.GetSheetObject("TB01")
set tbp = tb.GetProperties
set cols = tbp.Layout.ColLayouts
cols.Item(0).Label.v = "New Name"
tb.SetProperties tbp
End Sub
This is for a TableBox with ID = TB01. This changes the first label. Modify the number in Item(x) to the column you want to change (it starts with 0). Cols is an array, so you can cycle through the list if you would like. Check the APIGuide for more information.
Hi,
Does it have to be a macro that changes the label? Or can you use a variable instead?
Thanks
Nick
Sub TableBox
set tb = ActiveDocument.GetSheetObject("TB01")
set tbp = tb.GetProperties
set cols = tbp.Layout.ColLayouts
cols.Item(0).Label.v = "New Name"
tb.SetProperties tbp
End Sub
This is for a TableBox with ID = TB01. This changes the first label. Modify the number in Item(x) to the column you want to change (it starts with 0). Cols is an array, so you can cycle through the list if you would like. Check the APIGuide for more information.
Thanks Miller.
Its working fine
-Sathish
Hi Miller,
if i want to change chart straight table then this macro gives error. In straight table, How i pass dimension label name in macro???
-Sathish
The macro is a little different when working with a chart. For some reason, on a chart, the Dimension Label Attribute is called Title. Try this:
Sub Test
set chart = ActiveDocument.GetSheetObject("CH01")
set cp = chart.GetProperties
set dims = cp.Dimensions
dims(0).Title.v = "Test"
chart.SetProperties cp
End Sub
Similarly to the above, the dimensions are an array, so you will need to choose the right element or you can loop through them.
Hi
If you have a table with all columns qualified, a common task in table charts is to set the column labels to unqualified names. So e.g. x.y becomes y. This macro does this for you:
Call UnqualifyAllTableColumnLables("TB01")
Sub UnqualifyAllTableColumnLables(theTable)
Set tb = ActiveDocument.GetSheetObject(theTable)
Set tbp = tb.GetProperties
Set cols = tbp.Layout.ColLayouts
For i = 0 to tb.GetColumnCount-1
Set fld = tb.GetField(i)
If (Len(cols.Item(i).Label.v) = 0) Then cols.Item(i).Label.v = Mid(fld.Name,Instrrev(fld.Name,".")+1,999)
Next
tb.SetProperties tbp
End Sub
Marcel