6 Replies Latest reply: Apr 28, 2016 3:46 PM by payal pg RSS

    difficulties with macros

    payal pg

      Hi Qlik community,

      Am running Macros for "copy object" , Export Excel and Export email using the following script. copy object is working in my local the moment when i published into the server (AJAX) none of them are working .please help me



      "Copy object"

      Sub copy()


      End Sub   

      "Export Excel"


      FUNCTION ExcelExport(objID)

        set obj = ActiveDocument.GetSheetObject( objID )

        w = obj.GetColumnCount

        if obj.GetRowCount>1001 then


        else h=obj.GetRowCount

        end if

        Set objExcel = CreateObject("Excel.Application")



        objExcel.Visible = True

        set CellMatrix = obj.GetCells2(0,0,w,h)

        column = 1

        for cc=0 to w-1

         objExcel.Cells(1,column).Value = CellMatrix(0)(cc).Text

         objExcel.Cells(1,column).EntireRow.Font.Bold = True

         column = column +1


        c = 1

        r =2

        for RowIter=1 to h-1

          for ColIter=0 to w-1

            objExcel.Cells(r,c).Value = CellMatrix(RowIter)(ColIter).Text

            c = c +1


         r = r+1

         c = 1





      SUB CallExample

         ExcelExport( "CH12" )

      END SUB


      Here i use CallExample as the macro Action name



      Export email

      sub mSendMail

                Dim objOutlk 'Outlook

                Dim objMail 'Email item

                Dim strMsg

                dim strMailTo

                dim sString

                dim oldFormat

                Dim Rng

                Const olMailItem = 0

                Const CdoReferenceTypeName = 1

                Set objOutlk = CreateObject("Outlook.Application")

                Set objMail = objOutlk.createitem(olMailItem)

                Set Rng = Nothing

                objMail.To = "amit.kumar@teamcomputers.com"

                objMail.subject = "OMS DASHBOARD"

                ActiveDocument.GetSheetObject("CH12").CopyBitmapToClipboard.CopyBitmapToClipboard true

                ActiveDocument.Sheets("Dashboard-email").ExportBitmapToFile "\\\Documents\OMS DASHBOARD.jpeg"

                objMail.attachments.add("\\\Documents\OMS DASHBOARD.jpeg")

                strMsg = "This is an automatic generated email from QlikView for OMS DASHBOARD."

                objMail.body = strMsg

          objMail.HTMLBODY = "<HTML><BODY><img align=baseline border=0 hspace=0 src='cid:\\\Documents\OMS DASHBOARD.jpeg'</BODY></HTML>"


                Set objMail = Nothing

                Set objOutlk = Nothing

          Msgbox " Mail delivered"

      end sub

      Please help me with This