Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

AddTextFormatExpression

Hi,

I am trying to set text format via a macro instead of going through my targeted individual cells to set the format. I am sure I am doing something wrong here, but hoping someone can point me to the right direction.

Sub DEV

'get an object

set chart = ActiveDocument.GetSheetObject("CH01")

'get the number of expression

totExpr = chart.GetProperties.Expressions.Count

msgbox("# of Expressions = " & totExpr)

chart.AddTextFormatExpression "'<B>'"

     

End Sub

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

Are you trying to format all of your expressions as bold ?

If that's the case, you only need to add a for..next like this:

Sub DEV

'get an object
set chart = ActiveDocument.GetSheetObject("CH01")

'get the number of expression
totExpr = chart.GetProperties.Expressions.Count
msgbox("# of Expressions = " & totExpr)

'loop and set all expressions as bold
for i = 0 to totExpr-1
chart.AddTextFormatExpression "'<B>'",i
next

End Sub

Hope that helps.

View solution in original post

4 Replies
Not applicable
Author

Hi,

Are you trying to format all of your expressions as bold ?

If that's the case, you only need to add a for..next like this:

Sub DEV

'get an object
set chart = ActiveDocument.GetSheetObject("CH01")

'get the number of expression
totExpr = chart.GetProperties.Expressions.Count
msgbox("# of Expressions = " & totExpr)

'loop and set all expressions as bold
for i = 0 to totExpr-1
chart.AddTextFormatExpression "'<B>'",i
next

End Sub

Hope that helps.

Kushal_Chawda

Hi

No need to use macro here.

You can achieve this using pivot table with custom cell format setting

Create pivot table as attached in application.

For total check partial sum in presentation tab of chart.

For activating custom format cell setting. go to User preference>design> check Always show Desin item Menu

Now right click on chart > click custom format cell > select the required cell to customize (in your case sum(cost)) and check bold..

Not applicable
Author

Thank you for your help. It works great.

My bad here, rookie mistake/oversight.

Not applicable
Author

Hi Kush,

I need to use macro because expressions in my actual report will be bold or italic based on other condiitions, and I do not want to manually set their formats every time I update the report.

But thank you for pointing out the trick though, definitely good to  know.