Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.
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..
Thank you for your help. It works great.
My bad here, rookie mistake/oversight.
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.