Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

New Contributor II

difficulties with macros

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


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

6 Replies

Re: difficulties with macros

the moment when i published into the server (AJAX) none of them are working

Macro's like that don't work on the server. The ajax client runs in a browser. It can't run the macro code to create an excel instance or an outlook instance. You can try using IE and the IE plugin. Perhaps that combination works.

talk is cheap, supply exceeds demand
New Contributor II

Re: difficulties with macros

Hi Wassenaar,

Thanks for the Quick Reply, i just uploaded QVW into Access point,its not working.Please reply here

Re: difficulties with macros

Hi, if installing desktop version is an option, users with the need to use the macro can open the document in server using desktop.

Note that users must allow system access to macro security, wich is not the default option.

New Contributor II

Re: difficulties with macros

Hi Ruben marin,

Thanks for your reply, i didn't get you.But my problem is the script which i posted earlier is not working in Access point. One of the script which is copy object is Working at desktop ,but not in Access point.

Thanks in Advance

Re: difficulties with macros

Hi, as Gysbert saids, it won't work on Access Point, AJAX won't allow the macro to access the hard drive (so you can't create the excel or the mail), I don't know if there is a way of make that work using IE plugin, it will be good (or worrisome for security reasons) to know a way.

Sorry to say but the only option I know to use macros that requires system access is using desktop, I just was trying to give a workaround in case some remote users needs to use the macro, wich is open the documents in server using desktop, not using Access Point.

New Contributor II

Re: difficulties with macros

Thanks for you reply Ruben.

Community Browser