Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro for changing transparency

Hi everybody,

I am currently working with multiple hidden buttons laying over a pivot table. For maintainability reasons, I would like to change the transparency of all buttons with one macro. I tried to make a macro, but could not find the method in the API guide.

Can you guys help me out?

The macro I wrote so far:

sub FixObjects
for s = 0 to ActiveDocument.NoOfSheets - 1
    set vSheet= ActiveDocument.GetSheet(s)
    Objects = vSheet.GetSheetObjects
    For i = lBound(Objects) To uBound(Objects)
        set vObject = Objects(i)
        set vObjectProp = vObject.GetProperties
        vOK = 0
        'button object...
        if vOK=0 AND vObject.GetObjectType = 5 then
           vObjectProp.Frame.AllowMoveSize = false
           vOK = 1
        end if
        'chart object...
        if vOK=0 AND ((vObject.GetObjectType >=10 AND vObject.GetObjectType <=16) OR (vObject.GetObjectType >=20 AND vObject.GetObjectType <=22)) then
           vObjectProp.GraphLayout.Frame.AllowMoveSize = false
           vOK = 1
        end if
        'any other object...
'        if vOK=0 then
'           vObjectProp.Layout.Frame.AllowMoveSize = false
'           vOK = 1
'        end if
'        if vOK=0 then
'            msgbox(vObject.GetObjectType)
'        end if
        vObject.SetProperties vObjectProp
    Next
next
end sub

sub ChangeTransparency
for s = 0 to ActiveDocument.NoOfSheets - 1
    set vSheet= ActiveDocument.GetSheet(s)
     Objects = vSheet.GetSheetObjects
     For i = lBound(Objects) To uBound(Objects)
          set vObject = Objects(i)
          set vObjectProp = vObject.GetProperties
          vOK = 0
          'button object...
          if vOK=0 AND vObject.GetObjectType = 5 then
                   

                   ' The code for setting the transparency

                   vOK = 1
          end if
         vObject.SetProperties vObjectProp
     Next
next
end sub

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

The IButtonProperties class should work.

For Daniel's reply: The button backgroung color can be a calcualted color. That's where you would use the expression.

View solution in original post

7 Replies
m_woolf
Master II
Master II

I haven't used this so this is just a suggestion. Try looking for Alpha or BkgAlpha in the API Guide.

danielrozental
Master II
Master II

A simpler way would be to use argb($(variabletransparency), R, G, B) function as background color.

Then you can use an action (even simpler than a macro) to change the transparency factor variable.

Not applicable
Author

@mwoolf: The class 'button' does not seem to contain the member 'layout', which is required to use BkgAlpha or Alpha.


@Daniel: Is it possible to use an expression for the background of a button? I cannot find it at the moment.

Thanks for the quick responses so far!

m_woolf
Master II
Master II

The IButtonProperties class should work.

For Daniel's reply: The button backgroung color can be a calcualted color. That's where you would use the expression.

danielrozental
Master II
Master II

You can enter an expression there

button.png

Not applicable
Author

Thank you guys, I haven't used this api guide before so I had difficulty finding it..

danielrozental
Master II
Master II

You should really try avoiding Macro's when possible as they have several negative effects.

Look at the attached document.