Qlik Community

QlikView Deployment

Discussion Board for collaboration related to QlikView Deployment.

sathishkumar_go
Contributor III

How to use macro for Change label Name in Table Box

Hi,

Can some one give me macro code , For changing label Name in Table Box.

Sathish

1 Solution

Accepted Solutions
Not applicable

How to use macro for Change label Name in Table Box

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.

6 Replies
Not applicable

How to use macro for Change label Name in Table Box

Hi,

Does it have to be a macro that changes the label? Or can you use a variable instead?

Thanks

Nick

Not applicable

How to use macro for Change label Name in Table Box

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.

sathishkumar_go
Contributor III

How to use macro for Change label Name in Table Box

Thanks Miller.

Its working fine

-Sathish

sathishkumar_go
Contributor III

How to use macro for Change label Name in Table Box

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

Not applicable

How to use macro for Change label Name in Table Box

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.

hugmarcel
Contributor III

Re: How to use macro for Change label Name in Table Box

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

Community Browser