Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Run macro on QlikView Server 11

Hi, I need your help and I hope someone can help to me.

I´m trying to run a macro that switch different sheets on the qvw but the macro doesnt run. Then I tried with variables and the conditional statements on every sheet but it doesnt work.

This is the macro:

SUB ActivaHoja

   

   

    For i= 1 to 50000

        ActiveDocument.Sheets("Portada").Activate

        ActiveDocument.GetApplication.WaitForIdle

        ActiveDocument.GetApplication.Sleep 5000

   

        ActiveDocument.Sheets("Proporción").Activate

        ActiveDocument.GetApplication.WaitForIdle

        ActiveDocument.GetApplication.Sleep 5000

       

        ActiveDocument.Sheets("Proporción Imp").Activate

        ActiveDocument.GetApplication.WaitForIdle

        ActiveDocument.GetApplication.Sleep 5000

       

        ActiveDocument.Sheets("Detalle").Activate

        ActiveDocument.GetApplication.WaitForIdle

        ActiveDocument.GetApplication.Sleep 5000

        ActiveDocument.Sheets("Año Mes").Activate

        ActiveDocument.GetApplication.WaitForIdle

        ActiveDocument.GetApplication.Sleep 5000               

    NEXT

END    SUB

3 Replies
theivestjens
Contributor II
Contributor II

Does it work when you run it manually ?

With me this works manually but not on the server.

=====================

FUNCTION ExportObjectToJpg(SheetID, ObjID, fName)

  set s=ActiveDocument.GetSheetById(SheetID)

  set sp=s.GetProperties

  sp.Show.Always = true

  s.SetProperties sp

  s.Activate

  for i=0 to s.NoOfSheetObjects-1

      if s.SheetObjects(i).GetObjectId = ObjID then

          ActiveDocument.GetApplication.WaitforIdle

          s.SheetObjects(i).ExportBitmapToFile fName

      end if   

  next

END FUNCTION

SUB CallExample

  set ss= ActiveDocument.GetSheet(2)

  ExportObjectToJpg "Document\SH03", "Document\CH01", "U:\Calls_650.jpg"

ActiveDocument.GetApplication.Sleep 2000

  set ss= ActiveDocument.GetSheet(3)

   ExportObjectToJpg "Document\SH04", "Document\CH04", "U:\Calls_651.jpg"

  ActiveDocument.GetApplication.Sleep 2000

   set ss= ActiveDocument.GetSheet(4)

ExportObjectToJpg "Document\SH05", "Document\CH05", "U:\Calls_652.jpg"

END SUB

ashfaq_haseeb
Champion III
Champion III

Hi,

Did you try to run via IE Pluggin.

With ajax macros does not work.

Regards

ASHFAQ

theivestjens
Contributor II
Contributor II

You can try to do this with a script outside of Qlikview.

This works with me (automaticly)

Here a part of the script

+++++++++++++++++++++++++++

'Initialyze the Variables

Set Qv = CreateObject("QlikTech.QlikView")

Set QvDoc = Qv.OpenDoc("Open_document", "User", "Password")

Set ActiveDocument = QvDoc

QvDoc.Reload

QvDoc.GetApplication.WaitForIdle 'Application Waits till responding

QvDoc.Save

QvDoc.GetApplication.WaitForIdle

WScript.Sleep 2000    'Application Waits 2 seconds

'Application Selects the Chart and exports this to a Picture

ActiveDocument.GetSheetByID("SH01").Activate

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.GetSheetObject("CH01").ExportBitmapToFile "C:\temp\Filename_1.jpg"

WScript.Sleep 2000

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.GetSheetByID("SH02").Activate

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.GetSheetObject("CH04").ExportBitmapToFile "C:\temp\Filename_2.jpg"

WScript.Sleep 2000

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.GetSheetByID("SH05").Activate

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.GetSheetObject("CH05").ExportBitmapToFile "C:\temp\Filename_3.jpg"

ActiveDocument.GetApplication.WaitForIdle

ActiveDocument.GetApplication.Quit

++++++++++++++++++++++++

This script is started from task scheduler in Windows