Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
curiousfellow
Specialist
Specialist

Close qvw after reload script ended

I have a qvw (A) with a macro that opens another qvw(B)

When B is opened a macro is started that  starts a reload script. At the end of the reload script a string is stored to a txt file and a batch file is started.

Al that works perfect. However I don't succeed in closing B after the reload script of B has finished.

When I use a macro as below, qvw B is not opened, and when I delete the closing part B does not close.

I tried several scenarios to close B but I don't get the result I want. It seems that this part 'v.SetContent Var.GetContent. String,true' starts when the macro went through all the code. Putting the closing part in a seperate macro does not help either.

This is my vbcode:

sub open_attachment_app

set Var=ActiveDocument.Variables("number_invoice")
set App=ActiveDocument.GetApplication

set UserFile = App.OpenDoc ("E:\\qvdata\retrieve invoice.qvw","","")
set v = UserFile.Variables("number_invoice")

v.SetContent Var.GetContent. String,true

'this is the closing part
ActiveDocument.GetApplication.Sleep 5000

set newApp = ActiveDocument.GetApplication

set newdoc = newApp.OpenDoc ("E:\\qvdata\retrieve_invoice.qvw","","")

newdoc.GetApplication.WaitForIdle

newdoc.closedoc


end sub

 

Changing "newdoc"  to "Userfile" does not make any difference

We are using Qlikview May 2021 SR1

Labels (2)
1 Solution

Accepted Solutions
marcus_sommer

The following should work:

sub open_attachment_app

set Var=ActiveDocument.Variables("number_invoice")
set App=ActiveDocument.GetApplication

set UserFile = App.OpenDoc ("E:\qvdata\retrieve invoice.qvw","","")
set v = UserFile.Variables("number_invoice")

v.SetContent Var.GetContent.String,true

'UserFile.reload
'UserFile.save
UserFile.closedoc

end sub

- Marcus

View solution in original post

4 Replies
Maria_Halley
Support
Support

@curiousfellow

 

I am moving this to the App development so you reach the right audience with this question.

marcus_sommer

The following should work:

sub open_attachment_app

set Var=ActiveDocument.Variables("number_invoice")
set App=ActiveDocument.GetApplication

set UserFile = App.OpenDoc ("E:\qvdata\retrieve invoice.qvw","","")
set v = UserFile.Variables("number_invoice")

v.SetContent Var.GetContent.String,true

'UserFile.reload
'UserFile.save
UserFile.closedoc

end sub

- Marcus

curiousfellow
Specialist
Specialist
Author

Thank you @marcus_sommer . this worked allthough I don't understand why the reload does not work when I open B.

For the ones who want to use this code too : I had to remove the single quote before 'UserFile.reload and'Use.File.save

 

marcus_sommer

OnOpen triggers are often restricted from various issues, for example timing parameter caused from a parallel respectively multi-threaded execution, for security reasons and usability aspects. This means they may work within your current context but mostly it's better to find other and more stable ways to perform the wanted tasks.

The comment of the reload/save-statement was just a hint because I missed anything useful within your snippet but I didn't want that they would be immediately active in the case you copy & paste it.

- Marcus