Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
rustyfishbones
Master II
Master II

Macro to Assign Alternate States to All objects in a Sheet

Hi All,

I have 3 sheets, I want to create a macro that will assign all objects with the same Alternate State.

I have lots of objects on each sheet, so I want to save time

Tab1 = All Objects need assigned Alternate State Alt1

Tab2 = All Objects need assigned Alternate State Alt2

Tab3 = All Objects need assigned Alternate State Alt3


Is it possible, it would be a huge time saver


Thanks


Regards


Alan

5 Replies
marcus_sommer

AFAIK no - Re: Create state with an action.

- Marcus

rustyfishbones
Master II
Master II
Author

Hi Marcus,

I have got as far as being able to display the Alternate State in a message

the below code loops through the sheets and displays the Alternate State for each object on each sheet, now I just need to assign a value, I have tried a number of things, but still cannot get it to work

SUB AlternateStates()

ON ERROR RESUME NEXT

FOR i = 0 TO ActiveDocument.NoOfSheets - 1

  SET vSheet = ActiveDocument.GetSheet(i)

  msgbox vSheet

  Objects = vSheet.GetSheetObjects

  FOR j = lBound(Objects) To uBound(Objects)

  SET vObject = Objects(j)

  SET vObjectField = vObject.GetField

  

  msgbox (j & " has an Alternate State of " & vObjectField.GetStateName)

  NEXT

NEXT

END SUB

rustyfishbones
Master II
Master II
Author

Apologies, first msgbox should be i, no vSheet

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Not your specific question, but can you you assign the SHEET to an alternate state and used <inherited> for the objects?

-Rob

rustyfishbones
Master II
Master II
Author

Wow, how simple is that.......

I feel like an idiot, much easier solution Rob