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: 
m_woolf
Master II
Master II

vba macro to open, reduce data and close

I want to create a macro to open a qvw, reduce the data (remove all values), save and close the qvw.

I have code that will open and close the qvw.

What I need is code that will remove all values. Activedocument.reducedata doesn't work.

Also when I do activedocument.save, it prompts me for a file name. I just want it to save with no prompt.

Any suggestion?

1 Solution

Accepted Solutions
Gysbert_Wassenaar

ActiveDocument.SaveAs with the original file name as argument works for me to prevent the prompt.

If you need to remove all data you could create an array of the field names add pass those as second parameter to ActiveDocument.ReduceData. See attached example. In the example I hardcoded the array, but you should be able to create this by looping through the fields returned by ActiveDocument.GetFieldDescriptions.


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

ActiveDocument.SaveAs with the original file name as argument works for me to prevent the prompt.

If you need to remove all data you could create an array of the field names add pass those as second parameter to ActiveDocument.ReduceData. See attached example. In the example I hardcoded the array, but you should be able to create this by looping through the fields returned by ActiveDocument.GetFieldDescriptions.


talk is cheap, supply exceeds demand
marcus_sommer

Perhaps reducedata is not allowed:

temp=ActiveDocument.GetProperties.UserPermissions.ReduceData

if not temp then msgbox("Reduce Data is not allowed")

and/or it removed also path/filename (bug/feature). This could solved per ActiveDocument.SaveAs.

- Marcus