Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
traceyamcb
New Contributor II

Auto populate date in filename

Good morning,

Using Qlikview version 11, 64-bit edition

I am creating a button for people to easily to print an entire sheet. However, I have an issue in regards a macro i am using to copy an entire sheet to a png/pdf file.

The macro i am using is:

Sub export

ActiveDocument.ActiveSheet.FitZoomToWindow

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.ActiveSheet.ExportBitmapToFile "C:\Users\Administrator\Desktop\Pending Faults **where current date needs to be**.png"

End sub

I am in the process of transferring some of my Excel reports into Qlikview. For those in my team who use the report, they don't have to worry about the naming convention and the location to copy too, it's all done for them at the click of a button. The Excel macro i use is:

Sub SaveAsPdf()

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

        "Y:\Users\Administrator\Desktop\Pending Faults " & Format(Now() , "YYYYMMDD") & ".pdf", Quality _

        :=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _

        OpenAfterPublish:=True

End Sub

How do i go about getting the date working the same in Qlikview as i had in Excel?

Many thanks for your assistance.

Tracey

3 Replies

Re: Auto populate date in filename

Hi Tracey,

Sub export

vPath  = "Y:\Users\Administrator\Desktop\Pending Faults"

vToday = ActiveDocument.Evaluate("Date(Today(), 'YYYYMMDD')")

ActiveDocument.ActiveSheet.FitZoomToWindow

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.ActiveSheet.ExportBitmapToFile  vPath &"\" & vToday & ".png"

End sub

Re: Auto populate date in filename

If you want the user to enter the path dynamically, you can use variables in front end. I have attached a sample for your reference. Also, you can find the API guide in below link. You can search qlikview macro examples and syntaxes easily. Good luck.

API GUIDE

Capture.PNG

traceyamcb
New Contributor II

Re: Auto populate date in filename

Thank you for your reply. This worked very well

I have another question in regards pulling several macros through together, which i will post in another thread.

Kindest Regards

Tracey