Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Trouble with Macros

I'm trying to create a macro to export a chart as a JPG file.

From within the Edit Script (Ctrl-E) I have added a new tab and entered the following

FUNCTION ExportObjectToJpg( ObjID, fName)

  ActiveDocument.GetSheetObject(ObjID).ExportBitmapToFile fName

END FUNCTION

SUB CallExample

  ExportObjectToJpg "CH01", "C:\CH01Image.jpg"

END SUB

The following error is displayed

Unknown statement

FUNCTION ExportObjectToJpg( ObjID, fName)

  ActiveDocument.GetSheetObject(ObjID).ExportBitmapToFile fName

END FUNCTION

SUB CallExample

  ExportObjectToJpg "CH01", "C:\CH01Image.jpg"

END SUB

I obtained the script from here:

QlikView Macros – Useful collection | Lucian Cotea

and also tried

FUNCTION RunExe(cmd) 

  CreateObject("WScript.Shell").Exec(cmd)

END FUNCTION

SUB CallExample

  RunExe("c:\Program Files\Internet Explorer\iexplore.exe")

END SUB

which again fails.

I'm at a loss, any help greatly appreciated.

13 Replies
jerrysvensson
Partner - Specialist II
Partner - Specialist II

onpostreload.jpgYes you need to add a trigger to the event OnPostReload

Not applicable
Author

Hi Fernando, Think you posted just after me. Macro now working, but need it to run automatically after an update.

I need to use the "on postreload" option I believe, so just need to work out how.

thanks

steve

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Add an Action.

Action Type . External

Action : Run macro.

Not applicable
Author

Got it working finally. Wasn't sure what macro name to use. Second name worked so all is good.

Thank you all for your help.