Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

close macro problem

Hi all,

Sub NewQVWFile

set NewTest = ActiveDocument.GetApplication

NewTest.CreateDoc.SaveAs("C:\Users\admin\Desktop\NewApp's\first.qvw")

NewTest.CloseDoc //error generating here

End Sub

i tried above macro code for creating new QVW file and save and then close the first.qvw file.

the above macro is creating new qvw file and saving the file as first.qvw upto here it is working fine

but while coming closing the first.qvw file creating problem.

Please can anyone help in this ?

Thanks in advance.

5 Replies
SunilChauhan
Champion II
Champion II

see the attached file

only you need to do is change the path of this  test application in macro

hope this helps

Sunil Chauhan
Not applicable
Author

hi sunil, thanks for your reply.

i tried below macro its working fine.

Please can you cross check below macro and suggest me whether we are having any other better approach to acheive like this.

[Note : please check performance perspective also]

Sub NewQVWFile

set NewFile = ActiveDocument.GetApplication

NewFile.CreateDoc.SaveAs("C:\Users\admin\Desktop\NewApp's\first.qvw")

set app = NewFile.OpenDoc("C:\Users\admin\Desktop\NewApp's\first.qvw","","")

rem ** add new line to script **

set docprop = app.GetProperties

docprop.Script = docprop.Script & "LOAD * FROM [..\InputFields\RTQMain.qvd](qvd);"

app.SetProperties docprop

app.Reload

app.save

End Sub

Thanks in advance.

SunilChauhan
Champion II
Champion II

Sub NewQVWFile

set NewFile = ActiveDocument.GetApplication

NewFile.CreateDoc.SaveAs("C:\Users\admin\Desktop\NewApp's\first.qvw")

set app = NewFile.OpenDoc("C:\Users\admin\Desktop\NewApp's\first.qvw","","")

rem ** add new line to script **

set docprop = app.GetProperties

docprop.Script = docprop.Script & "LOAD * FROM [..\InputFields\RTQMain.qvd](qvd);"

app.SetProperties docprop

app.Reload

app.save

End Sub

i thing there is no need of  line in bold

else its working.

Sunil Chauhan
Not applicable
Author

Hi Sunil,

First time i am having only one application i.e; "CreateQVWFile.qvw"

In the above qvw file having a button action that contains action like to create new qvw file & save  and reload the given qvd.

After clicking the button it create new qvw file "First.qvw".

So that why we are creating new QVW file.

Thanks in advance.

Not applicable
Author

Hi sunil,

I tried below macro code for adding new script line into existed tab "Main 2" ,

but the below code works like creating another new tab "Main 2" and adding the script line as $(Include=d:\vqd eat\text\test.txt);

what to change in below code for add new script line into existed tab "Main 2" ?

docprop.Script = docprop.Script & chr(13) & chr(10) & "///$tab Main 2" & chr(13) & chr(10) & "$(Include=d:\vqd eat\text\test.txt);"

Thanks in advance