Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
suryakant241187
Partner - Contributor III
Partner - Contributor III

Help in qlikview macro

Hello Team,

I need one help. I have written one macro which is producing the dashboards in form of images and saving it as an name_id_date.

but now when i exporting the images i am getting the mismatch in the name and data of dashboard. i.e. it is saving the dashboard by giving the other name. below is my code:

Sub Export_Report

ActiveDocument.Sheets("SH01").Activate

sPCode = ActiveDocument.Variables("vPCode").GetContent().String

ExpPath = ActiveDocument.Variables("vExPath").GetContent().String

ActiveDocument.ClearAll 'The sheets need to be cleared'

'msgbox sPCode

ActiveDocument.Fields("PRACTICE_CODE").select sPCode

sPCode=left(sPCode,3)

'Check if selections have been made, multiple selections are not OK, thus the LEN(SPCode) check

'The month will most likely be redundant

If lEN(sPCode) <> 3 Then

    msgbox("You have to select a Practice Code. No reports will be written")

  EXIT SUB

End If

'Get the possible values for the current selection in ID!!?

set mySelections = ActiveDocument.Fields("ID").GetPossibleValues(999999)

set myName = ActiveDocument.Fields("EMPLOYEE_NAME").GetPossibleValues(999999)

Dim loadDate

Dim i

Dim Fieldvalue

Dim Filename

dim empName

dim empid

set empid=ActiveDocument.Variables("perId")

empidval=empid.GetContent.String

'set aa=GetFieldSelections("ID")

'msgbox empidval

ReportPeriod = ActiveDocument.Variables("vReferenceDate").GetContent().String

FileName = ExpPath & SPCode & "\"

result1 = msgbox("All files in" & Filename & " will be deleted. Continue? " ,vbYesNoCancel,"Continue?")

If result1 = 7 Or result1 = 2 Then

    EXIT SUB

End If

'DeleteFiles(FileName)

result2 = msgbox("Reports for" & mySelections.Count & " employees will be written for practice " & SPCode & ". Continue? " ,vbYesNoCancel,"Continue?")

If result2 = 7 Or result2 = 2 Then

    EXIT SUB

End If

'Set up the document for export! Yes this is needed

FieldValue = mySelections.Item(0).text

ActiveDocument.Fields("ID").select FieldValue

empName=myName.Item(0).Text

ActiveDocument.Fields("EMPLOYEE_NAME").select empName

'Message box below is needed, it is a workaround !!! Can not be removed since it refreshes the sheet.

'Otherwise, the first employee will get the report of the next comming in the loop

ActiveDocument.Sheets("SH01").SheetObjects("CH49").Activate

              for i = 0 to mySelections.Count - 1

              'for i = 0 to 50

             'dim FieldValue

             'dim mnth

           

                    FieldValue = mySelections.Item(i).text

                    empName = myName.Item(i).text

                    'If an employeeid does not exist in month then a file is still written

                    ActiveDocument.Fields("ID").select FieldValue

                    'For some reason this has to stay inside the loop, hard setting???

                    ActiveDocument.Fields("PRACTICE_CODE").select SPCode

                    Application.Refresh

'ActiveDocument.ShowPopup "Ok", 10000

                    ActiveDocument.Sheets("SH01").SheetObjects("CH03").Activate

                    ActiveDocument.GetApplication.Waitforidle 200000

                    ActiveDocument.Sheets("SH01").SheetObjects("CH164").Activate

                    ActiveDocument.GetApplication.Waitforidle 200000

                    ActiveDocument.Sheets("SH01").SheetObjects("CH136").Activate

                    ActiveDocument.GetApplication.Waitforidle 200000

                    Application.Refresh

                    'ActiveDocument.GetApplication.Sleep 4000

                   

                    'Concatenate string of employee id (the Fieldevalue), Employee Name (emp_name), and the timestmp

                    'ActiveDocument.Sheets("SH01").ExportBitmapToFile FileName & FieldValue & "_" & emp_name & "_" & ReportPeriod & ".png"

                    Application.Refresh

                    ActiveDocument.GetApplication.Waitforidle 400000

                    'MsgBox("Click Ok")

                    'msgbox FieldValue

                    ActiveDocument.Sheets("SH01").ExportBitmapToFile FileName &  empName &"-"& FieldValue &"_" & ReportPeriod & ".png"

                    ActiveDocument.GetApplication.Waitforidle 400000

        Next

       

        msgbox(i & " number of reports have been written to " & FileName)

       

End Sub

Regards,

Suryakant

7 Replies
Anil_Babu_Samineni

i am not expert in Macro. But, Can you tell me the business whether how want to store report image into Path. We can store by help of macro only. But, We need to talk little more about business

He has Capable on Macro tamilarasu

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
suryakant241187
Partner - Contributor III
Partner - Contributor III
Author

e.g. in folder: with name_Id_date

D:/Docs

o/p name: Suryakant_1234_23_06_2017.png

Anil_Babu_Samineni

Last Question, What are these Name & Id ??

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
suryakant241187
Partner - Contributor III
Partner - Contributor III
Author

These are the details of peoples or whoes dashboards needs to be generate which i am loading through the excel file in qlikview.

this detail i am loading by using the excel.

suryakant241187
Partner - Contributor III
Partner - Contributor III
Author

Can i take the object value of textbox directly in macro? if yes please let us know. i

suryakant241187
Partner - Contributor III
Partner - Contributor III
Author

Hello,

Please help with the macro for exporting the bitmap image with name: Emplyeename_Id_date.

e.g. suryakant_1111_28_06_2017.

The name and Id details loading through the excel file.

Help is appreciated.

Regards,

Suryakant

tamilarasu
Champion
Champion

Hi Suryakant,

Is it possible to attach a sample file? If yes, it would be easy for us to help you quickly. Let us know.