Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I found the following in a previous post at Is it possible to write a function to print a sheet (not report)?
I do not know how to implement it. I am not sure where I put the sub portion and the function portion. Do I put the sub portion into a button with Action = Run macro? Where do I put the function?
-------------------------------------------------------------------------------------------------------
sub Export
tempFolder="D:\Upendra\"
reportName="TestDashboard"
reportFile = tempFolder & reportName & day(date) & monthname(month(date))&".pdf"
'msgbox reportFile
printReportPDF reportFile
ActiveDocument.GetApplication.Sleep 5000
ActiveDocument.sheets("SH05").Print
ActiveDocument.GetApplication.Sleep 5000
' SendMail
'msgbox "saved."
end sub
'===========================================================================
Function printReportPDF(pdfOutputFile)
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.RegWrite "HKCU\Software\QlikviewPDF\OutputFile", pdfOutputFile, "REG_SZ"
WSHShell.RegWrite "HKCU\Software\QlikviewPDF\BypassSaveAs", "1", "REG_SZ"
Set WSHShell = nothing
End function
Open your QVW and then press CTRL+M. That opens the macro editor and then you can paste the above code.
You need to update the macro code by providing a location that exists in your system.
tempFolder="D:\Upendra\"
and the Sheet ID of the sheet that you want to print.
ActiveDocument.sheets("SH05").Print
Make sure you have "Allow System Access" selected.
Create a button and then call the macro.
Thank you. This is great. I was wondering where do I call the function?