0 Replies Latest reply: Oct 5, 2017 4:06 PM by Rohit Bontalwar RSS

    Need Help With VBA Script to Export Multiple Object on Single .jpg Page

    Rohit Bontalwar

      I have multiple Objects(Line Chart, Text Object etc) on Sheet "SH39" and I want to export specific objects on single page in .jpg format using vba script.

      I am able to export either single object or screen shot of what is being displayed but not able to select and export multiple objects.

       

      Thanks in Advance.

       

      Sub QlikPrint()

       

       

          Dim Val As Variant

       

          On Error Resume Next

          Dim objQV As QlikView.Application

          Set objQV = GetObject(, "QlikTech.QlikView")

          If TypeName(objQV) = "Global" Then

                  boolLoopAgain = True

              Else

                  Set objQV = CreateObject("QlikTech.QlikView")

          End If

       

          Dim ObjDoc As QlikView.Document

          Set ObjDoc = objQV.OpenDoc("C:\..................................................................\TVM_Dashboard.qvw")

       

          ObjDoc.Fields("[Matched Pair Name (Dept Name)]").Select ""

       

          Dim strItemNm As String

       

          Set Val = ObjDoc.Fields("[Matched Pair Name (Dept Name)]").GetpossibleValues(200)

       

       

          For i = 0 To Val.Count - 1

              ObjDoc.GetApplication.WaitForIdle

              Debug.Print i & " of " & Val.Count

              Debug.Print Val.Item(i).Text

              ObjDoc.Fields("[Matched Pair Name (Dept Name)]").Select Val.Item(i).Text

              ObjDoc.GetApplication.WaitForIdle

       

              strItemNm = Replace(Val.Item(i).Text, "/", "_")

              MyCharts = ObjDoc.Sheets("SH39").GetSheetObjects

              MyChartsObj = ObjDoc.Sheets("SH39")

           

              MyCharts = ObjDoc.Sheets("SH39").GetSheetObjects

              MyChartsObj = ObjDoc.Sheets("SH39")

           

                  For x = LBound(MyCharts) To UBound(MyCharts)

                             Set obj = ObjDoc.Sheets("SH39").GetSheetObjects(x).GetObjectId

                             If obj="CH431_309715473" And obj="TX560"  And obj="TX558" Then

                                      obj.ExportBitmapToFile "C:\......................................................\Qlik Report\" & strItemNm & ".jpg"

                             End If

                  Next x

          Next i

      End Sub