Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
fineasfalco
Contributor III
Contributor III

Show/Hide chart title via VB Macro

Hi,

I have the need to show/hide the chart caption via macro.

The layout of the chart title is controlled by a check box (Show Caption) in Caption tab .

I have added a button to run a macro to check/uncheck this control

A possible VB sub routine:

SUB ShowHide_TITLE
set chart = ActiveDocument.GetSheetObject("CH29")

set Prop = chart.GetProperties
' ?????  Prop.???????=true
chart.SetProperties Prop

END SUB

is there a way for achieving this?

2 Solutions

Accepted Solutions
m_woolf
Master II
Master II

If any of the replies solved your problem, please mark as Correct. If any were Helpful, please mark as Helpful.

View solution in original post

fineasfalco
Contributor III
Contributor III
Author

Tkank you,

now the code is right.

Best Regards

Fineas

View solution in original post

7 Replies
m_woolf
Master II
Master II

This is from the API Guide:

set myobj = ActiveDocument.GetSheetObject("CO01")

prop = myobj.GetProperties

prop.Layout.Frame.ShowCaption = true

myobj.SetProperties prop

m_woolf
Master II
Master II

Since Macros are Bad, I should suggest another method:

You could clone your chart and remove the caption on the close. Then you could use an action to show/hide the charts based on a variable or a field selection.  No macros required.

fineasfalco
Contributor III
Contributor III
Author

Thank you very much for your support and prompt reply.

I'll use your suggestion.

I have another question, Where can I find the API Guide?

m_woolf
Master II
Master II

If any of the replies solved your problem, please mark as Correct. If any were Helpful, please mark as Helpful.

fineasfalco
Contributor III
Contributor III
Author

Tks for  the guide.

the solution to use a variable to show or not the cloned table can be the right idea.

In order to the macro, I have used your code but It's not run.

I'm using a pivot tables.

You say right about the macro (Macro are bad), but I have need to understand because the code is not right.
Your help is always precious.
Regards
Fineas

m_woolf
Master II
Master II

This code should work for a pivottable:

set mybox = ActiveDocument.GetSheetObject("CH07")

set fr = mybox.GetFrameDef

fr.ShowCaption = true

mybox.SetFrameDef fr

fineasfalco
Contributor III
Contributor III
Author

Tkank you,

now the code is right.

Best Regards

Fineas