Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Sub Import_Variables
Dim objQV, objSource, objDest, objSourceVar, objDestVar
Dim objVars, varcontent, objTempVar, varname, x, varFileName
'initialize
Set objQV=CreateObject("QlikTech.QlikView")
Set varFileName = "VOCvsCSIReport"
'Set objSource=objQV.OpenDoc("E:\TKMVOC\Extraction\DataModeller1.qvw")
Set objDest=objQV.OpenDoc("E:\TKMVOC\Application\Main.qvw")
set objSource = objDest.GetVariableDescriptions 'objVars
'Loop through the variables
for x = 0 to objSource.Count - 1
set objTempVar = objVars.Item(x)
varname=Trim(objTempVar.Name)
Set objSourceVar=objSource.Variables(varname)
varcontent=objSourceVar.GetRawContent
'display the variable to check on progress if needed
'msgbox(varname & " = " & varcontent)
'update the value of variable in Destination document
Set objDestVar=objDest.Variables(varname)
If objDestVar is nothing then
'must need to create variable
objDest.CreateVariable varname
Set objDestVar=objDest.Variables(varname)
End If
objDestVar.SetContent varcontent,true
next 'end of loop
'save Destination document if desired
objDest.Save(varFileName)
'we're done, close down
objSource.CloseDoc
'objDest.CloseDoc
'objQV.quit
'WScript.Quit
end sub
Sub ReloadApp
Set MyApp = createobject("QlikTech.QlikView")
Set MyDoc = MyApp.OpenDoc ("E:\TKMVOC\Extraction\DataModeller1.qvw")
MyDoc.GetApplication
MyDoc.Reload
ActiveDocument.GetApplication.Sleep 2000
MyDoc.Save
MyDoc.CloseDoc
'Sub ReloadApp
' ReloadDM
' ReloadExtraction
call Import_Variables
ActiveDocument.GetApplication.Sleep 2000
ActiveDocument.Reload
ActiveDocument.Save
msgbox("Refresh Done")
End Sub
Dim DateToday
Dim tempFolder
Dim SSIreportName
tempFolder = "E:\Reports\"
SSIreportName="SSI"
DateToday=day(now()) & "_" & month(now()) & "_" & year(now())
varYear=year(now())
varMonth=month(now())
varDay=day(now())
sub DailyVOC
Set Doc=ActiveDocument
Doc.ClearAll
'ActiveDocument.Reload
'set v1 = ActiveDocument.Variables("vMaxMonth")
'msgbox(v1)
'ActiveDocument.Fields("@ComplaintsYear").Select v1.GetContent.String
Set usrList = Doc.Fields("DealerZone").GetPossibleValues()
For l=0 to usrList.Count -1
i=right("000"&l+1, 4)
Doc.UnlockAll
Doc.Fields("DealerZone").Select usrList.Item(l).Text
currentUser=usrList.Item(l).Text
'msgbox(currentUser)
'call sendReport
call ExportPDF
a=i
call checkOutputFile("E:\PDF_Reports\PDFReport_"&i&".pdf","E:\TKMVOC\Reports\PDFReport_"&i&".pdf")
ActiveDocument.GetApplication.sleep 2000
i=a
Next
Set usrList=nothing
'Doc.ClearAll
call DeleteFiles
msgbox ("Process Completed")
'filesys.deletefile tempFolder & "*.*", True
end sub
''' reportFile = tempFolder &reportName ¤tUser& "_Daily VOC_"& DateToday & ".pdf"
sub ExportPDF
reportFile = tempFolder &SSIreportName ¤tUser& "_DailyVOC_"& DateToday & ".pdf"
'call printReportPDF(reportFile)
ActiveDocument.GetApplication.Sleep 2000
ActiveDocument.PrintReport "RP01", "PDF-XChange 5.0"
ActiveDocument.SaveAs(reportFile)
'ActiveDocument.GetApplication.Sleep 8000
end sub
Function printReportPDF(pdfOutputFile)
Set WSHShell = CreateObject("WScript.Shell")
'WSHShell.SetDefaultPrinter"QlikViewPDF"
WSHShell.RegWrite "HKCU\Software\Tracker Software\PDF-XChange 5.0\OutputFile", pdfOutputFile, "REG_SZ"
WSHShell.RegWrite "HKCU\Software\Tracker Software\PDF-XChange 5.0\BypassSave", "1", "REG_SZ"
Set WSHShell = nothing
End function
function checkOutputFile(pdfFile,copy)
Dim fileTest
Set fileTest = CreateObject("Scripting.FileSystemObject")
currentStatus = fileTest.FileExists (pdfFile)
if currentStatus = false then
rem ** let QV sleep for 1 seconds **
ActiveDocument.GetApplication.Sleep 1000
' checkOutputFile1(pdfFile)
end if
set fileTest = nothing
call MoveFile(pdfFile,copy)
ActiveDocument.ClearCache
end function
function MoveFile(pdfFile,copy)
reportFile = tempFolder &SSIreportName ¤tUser& "_Daily VOC_"& DateToday & ".pdf"
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(pdfFile)=True Then
filesys.CopyFile pdfFile, "E:\Reports\"
If filesys.FileExists(copy)=True Then
filesys.MoveFile copy ,reportFile
'''''call sendMail(reportFile)
end if
end if
set filesys = nothing
end function
sub DeleteFiles
Set filesys = CreateObject("Scripting.FileSystemObject")
filesys.DeleteFile "E:\PDF_Reports\PDFReport_0*"&a&".pdf"
end sub
Its getting save manually but not automatically Can anyone help in this regard