Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Excel VBA Code to close a Qlikview Document.

Hi All,

I have a below macro in excel which opens a qlikview document "Reloads" the data in it and saves it but I am unable to close the same using the vba code.

Sub RefreshQlikviewfile ()
Dim Fname As String

Fname = ThisWorkbook.Sheets(3).Cells(2, 2).Value

Set QvDoc = GetObject(Fname)
QvDoc.Reload
QvDoc.Save
End Sub

I tried to use the below code lines but any of them didn't work.

1) QvDoc.Quit

2) QvDoc.Exit

3) QvDoc.Close

Please help...

Thanks a lot for your help in advance.[:)]

3 Replies
vgutkovsky
Master II
Master II

Try this:


set Qv = CreateObject("QlikTech.QlikView")
set QvDoc = Qv.OpenDocEx (Fname,0)
QvDoc.Reload
QvDoc.Save
QvDoc.CloseDoc
Qv.Quit


If that doesn't work, then there's some restriction with Excel that I'm not aware of. In which case, you would probably need to kill the QV.exe process after the save:


Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& ".\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Qv.exe'")
For Each objProcess in colProcess
objProcess.Terminate()
Next


Regards,

Not applicable
Author

Hi Vlad,

Thanks a lot it's working fine now. Smile

Not applicable
Author

Thanks a Ton..