Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Macro to export Script

Hi,

It is possible to make a macro that copy all of the content in 'Edit Script' (obviously for every sheet in script) and export to Word Document or another format? (Excel,txt,csv?)

I tried a different things, search in community and read API Guide but I didn't find anything. Is there any function that allows me to do it?

Thanks in advance,

Daniel

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The script is contained in property

ActiveDocument.GetProperties.Script

So a quick macro to write the script from the current QVW to a text file could be:

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.OpenTextFile "C;\myfile.qvs", 2, True)

objTextFile.Write(ActiveDocument.GetProperties.Script)

objTextFile.Close()

If you download

Qlikview Cookbook: QVS Editor http://qlikviewcookbook.com/recipes/download-info/qvs-editor/

It contains macro code that reads & writes script.

-Rob

http://masterssummit.com

http://robwunderlich.com

View solution in original post

10 Replies
ecolomer
Master II
Master II

Yes, here you have some examples to excel and ppt (for word is similar)

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The script is contained in property

ActiveDocument.GetProperties.Script

So a quick macro to write the script from the current QVW to a text file could be:

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.OpenTextFile "C;\myfile.qvs", 2, True)

objTextFile.Write(ActiveDocument.GetProperties.Script)

objTextFile.Close()

If you download

Qlikview Cookbook: QVS Editor http://qlikviewcookbook.com/recipes/download-info/qvs-editor/

It contains macro code that reads & writes script.

-Rob

http://masterssummit.com

http://robwunderlich.com

ziadm
Specialist
Specialist

is it possible to post the macro in the blog. I have the personal edition

Not applicable
Author

Hi Rob,

I used the above snippet to create layout & script from my qvw files but in most of my files. I keep getting error in objTextFile.Write(ActiveDocument.GetProperties.Script) [Invalid procedure call or argument].It creates an empty file but is not able to write in the file. Its working if I use Admin access , I have read/write permission to the folder.

Sub SaveQvsLayout()

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objTextFile = objFSO.OpenTextFile ("E:\bb\analytics\qlikview\" & Right(replace(ActiveDocument.Name, ".qvw", ".qvs"),Len(ActiveDocument.Name)-InstrRev(ActiveDocument.Name,"\",-1)), 2, True)

    objTextFile.Write(ActiveDocument.GetProperties.Script)  'Error-Invalid procedure call or argument

    objTextFile.Close()

    ActiveDocument.ExportLayoutFile("E:\bb\analytics\qlikview\" & Right(replace(ActiveDocument.Name, ".qvw", ".xml"),Len(ActiveDocument.Name)-InstrRev(ActiveDocument.Name,"\",-1)))

End Sub

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

So it's working if you open the qvw with Admin access? Why not open them all with Admin then. Or is that not possible?

-Rob

Not applicable
Author

Hi Rob,

I am doing this to add all *.qvs/*.xml to version control. I have admin permissions but rest of the team doesn't so I wanted it to work for everyone. The only permission rest of the team doesn't have for E:\bb\analytics\qlikview\ is special permissions . I think that permission is responsible here I will try giving them that.

Not applicable
Author

Thanks for the answer and that is really helpful Rob.

But When I am trying to executed the macro code that you have provided me  I am getting follow error in my edit module window as -----  permission denied. Could you help me with some idea.

thank you.

marcus_sommer

You need to enable system-access within the modul security (left pane in the mid).

- Marcus

Not applicable
Author

Thank you Marcus, that worked for me.