Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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
Gysbert_Wassenaar

That code from Lucian works fine for me. Do you actually have a chart object with Id CH01?


talk is cheap, supply exceeds demand
Not applicable
Author

I Do, but as mentioned even the launch IE script won't work either.

i Must be missing something obvious.

fkeuroglian
Partner - Master
Partner - Master

Hi, it works fine for me

do you have this root path?

do you have permission to write in c:?

do you have select in combo box in macro ALLOW SYSTEM ACCES?

something in your configuration is the problem

good luck!

Fernando

Not applicable
Author

Where do I find

"select in combo box in macro ALLOW SYSTEM ACCESS?"

thanks

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Hi

just to make sure. You wrote Ctrl-E, that opens the script editor.

This code should go in macro editor Ctrl-M.

Not applicable
Author

Hi Jerry, you found the problem.

The macro now works, as you pointed out I had it in the script editor as I pointed in in my first post.

How do I call the macro to run when refreshing?

thanks

jerrysvensson
Partner - Specialist II
Partner - Specialist II

You can trigger your  macro on PostReload.

But you have to do a batch reload using qv.exe /r app.qvw, since triggers will not trigger if you run a standard Publisher task.

Not applicable
Author

Ok, created a DOS batch file which runs and updates the data, but does not create the jpg files.

Do I need a trigger in the file?

fkeuroglian
Partner - Master
Partner - Master

Hi, try this document and tell me how was