After a little vacation, let´s get to work.
I don´t know why, but I don´t like using the navigation tab buttons on my reports. Probably it is because I have to set lots of properties and create the same objects (filters, logo, report name, etc) for each of the tabs.
A couple of months ago I started using object´s conditional show to create a tab that would have all my objects. When pressing a "Dashboard" button, the dashboard objects would appear. When pressing a "Regional" button, only the regional objects would appear.
The biggest problem with this approach is that I needed to set individually the condition that would make the objects appear or not.
To make my job easier, I have come with the macro below so that I can write my condition, choose the objects I want and then set for all of them the same condition making the development and maintenance easier. It is almost a group condition.
WHAT
I have took the macro below and changed it a little to allow setting a "conditional show" for multiple objects.
HOW
You cannot use a button to call the macro. If you do, when pressing the buttons the objects you have selected to apply the macro will be deselected and the macro will be applied over the button. We need to make a little workaround when using the macro.
1. first create 2 vars:
vLayout and
vShowCondText.
2. copy the code to the Macro Module:
sub setShowCondition
' vars
set doc = ActiveDocument
' grab the text to be used as the condition
condText = ActiveDocument.Variables("vShowCondText").GetContent.String
' msgBox(condtext)
' traverse the selected objects setting the new condition text
set s=doc.ActiveSheet
objs=s.GetActiveSheetObjects
for i=lbound(objs) to ubound(objs)
' get the object's name and property
set objInt = objs(i)
objID = replace(objInt.GetObjectId,"Document\","")
set obj = doc.GetSheetObject(objID)
objProp = obj.GetProperties
' as each object has diferent places for the frame object, treat them differently
select Case objs(i).GetObjectType
Case 1,2,3,4,6,7,8,9,17,18,19,34,35 'LB,MB,SB,TB,TX,CS,IB,LA
objProp.Layout.Frame.Show.Always = false
objProp.Layout.Frame.Show.Expression.v = condText
Case 5,31 'BU,SO
objProp.Frame.Show.Always = false
objProp.Frame.Show.Expression.v = condText
Case 10,11,12,13,14,15,16,20,21,22,27,28 'CH's
objProp.GraphLayout.Frame.Show.Always = false
objProp.GraphLayout.Frame.Show.Expression.v = condText
Case Else
msgbox("ObjectID: " &objID & " with objectType: " & objs(i).GetObjectType &" couldn't be found, trying LB settings")
objProp.Layout.Frame.Show.Always = false
objProp.Layout.Frame.Show.Expression.v = condText
end select
obj.SetProperties objProp
next
end sub
USING THE MACRO
1. Create the button.
2. Configure it to set the value to the vLayout variable.
3. Write the condition you want. I have created an input object that will set automatically the value to the var
vShowCondText.
4. Select the objects you want to set the condition.
5. Now, the workaround part. Open the Module Screen (CTRL+M). Select the function
setShowCondition on the left side.
6. Below the function list, click the TEST button . It will execute the macro chosen before.
That´s it. When pressing the new button, the objects will appear. You may want to create a logic to set/unset the vLayout variable so that the same button enables/disables the objects, or create another button that will set another value to vLayout, making the objects with the value PRINCIPAL to disappear appearing the new ones.
Hope it helps. Please comment.