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()

      ActiveDocument.GetSheetObject("CH12").CopyBitmapToClipboard

      End Sub   


      "Export Excel"

       

      FUNCTION ExcelExport(objID)

        set obj = ActiveDocument.GetSheetObject( objID )

        w = obj.GetColumnCount

        if obj.GetRowCount>1001 then

          h=1000

        else h=obj.GetRowCount

        end if

        Set objExcel = CreateObject("Excel.Application")

        objExcel.Workbooks.Add

        objExcel.Worksheets(1).select()

        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

        next

        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

          next

         r = r+1

         c = 1

      next

      END FUNCTION

       

       

      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 "\\172.16.11.211\Documents\OMS DASHBOARD.jpeg"

                objMail.attachments.add("\\172.16.11.211\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:\\172.16.11.211\Documents\OMS DASHBOARD.jpeg'</BODY></HTML>"

                  objMail.Send

                Set objMail = Nothing

                Set objOutlk = Nothing

          Msgbox " Mail delivered"

      end sub


      Please help me with This