Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good morning,
i am using windows task scheduler and a .vbs file to automatically run some qlikview files.
Here is the code of the .vbs file:
dim fso
dim MyDoc
dim MyApp
dim qvwVerzeichnis
dim vVerzeichnis
dim vDirectory
dim vDatei
Dim intZaehler
set MyApp = CreateObject("QlikTech.QlikView")
set fso = CreateObject("Scripting.FileSystemObject")
'Set fso = New FileSystemObject
qvwVerzeichnis = "\\10.232.130.232\QlikView\data\02_Betriebsorganisation\TELSTAR\"
REM TEAMSTATISTIK
intZaehler = 0
SET vVerzeichnis = fso.GetFolder("\\DENW0043VF001\43daten\000Versicherungstechnik\ACD-Reporting\Teamreports\")
vDirectory = "\\DENW0043VF001\43daten\000Versicherungstechnik\ACD-Reporting\Teamreports\"
'Anzahl der Dateien im Ordner (ohne Unterverzeichnisse):
For Each vDatei In vVerzeichnis.Files
'Prüfen, ob es eine Datei ist, die im Namen "Advocard Teamauswertung I HalfHr Prozent" enthält
If Mid(vDatei.Name, 1, Len("Advocard Teamauswertung I HalfHr Prozent")) = "Advocard Teamauswertung I HalfHr Prozent" Then
'-->Dateizähler erhöhen:
intZaehler = intZaehler + 1
End If
Next
REM QVW-Datei Teamreports öffnen und Skript starten
if intZaehler >0 then
set MyDoc = MyApp.OpenDoc (qvwVerzeichnis + "qvdACR_Teamstatistik.qvw","","")
set ActiveDocument = MyDoc
ActiveDocument.Reload
Set MyDoc = Nothing
REM eingelesene Dateien in das Archivverzeichnis verschieben
fso.MoveFile vDirectory + "Advocard Teamauswertung I HalfHr Prozent*.xls", vDirectory + "archiv\"
end if
REM TELSTAR-Datenmodell
'QVW-Datei mit Datenmodell öffnen, Skript starten und speichern
set MyDoc = MyApp.OpenDoc (qvwVerzeichnis + "TELSTAR_datenmodell.qvw","","")
set ActiveDocument = MyDoc
ActiveDocument.Reload
ActiveDocument.Save
REM TELSTAR
'QVW-Datei TELSTAR öffnen, Skript starten und speichern
qvwVerzeichnis = "\\10.232.130.232\QlikView\data\Prod\TELSTAR\" ' für produktiv auskommentieren
set MyDoc = MyApp.OpenDoc (qvwVerzeichnis + "TELSTAR.qvw","","")
set ActiveDocument = MyDoc
ActiveDocument.Reload
ActiveDocument.Save
MyDoc.GetApplication.Quit 'Qlikview schließen
Set MyDoc = Nothing
Set MyApp = Nothing
Set fso = Nothing
As one can see, i am using vbs because I have to check whether there is at least a file in the directory, run the qvw and then move the files to a different directory.
Everything works fine except for the last file Telstar.qvw. Only for this one qv asks to manually replace the file:
All other files are automatically saved even without using 'ActiveDocumentSave'.
In different discussions I read about '/NoScript'. Is it possible to add this command in the .vbs file. If so - where?
Or is there any other possibility to run these kind of scripts automatically.
regards, Falko
It will help if you answer the following questions:
I think the problem is that this qvw has the "Initial Data Reduction..." option checked in Document Properties | Opening. If this option is set, then QV will automatically do a Save As... option to avoid the possibility of a reduced document overwriting the "unreduced" document.
Apart from clearing this option, I do not think there is a workaround, but perhaps someone else has an idea.
The same thing happens if you open the document in the desktop and then try to save it. You could possibly invoke Qv.exe with the /R option from your script. This does not have the same problem.
If so, problem may be solved by simply saving document before reload:
ActiveDocument.SaveAs ActiveDocument.GetPathName;
ActiveDocument.Reload;
ActiveDocument.Save;
ActiveDocument.CloseDoc;
That's it!
the combination of yours and jonathan's answer finally made it for me!
Now I can really start to let task scheduler do it's daily job.
Thanks a lot!