Herman,

I tried to use the OLE interface from within AFL to export an image using a 
ParamTrigger. But, I could not get it to work. There have been numerous posts 
and examples in the documentation saying that it *should* work. But, for me it 
simply would not :(

So, the work around that *does* work is to write a javascript file like this 
(say c:\myscripts\saveimage.js):

Args = WScript.Arguments;
AB = new ActiveXObject("Broker.Application");
Win = AB.ActiveWindow;
Win.ExportImage(Args(0));

Then create a custom tool in AmiBroker via:
- "Tools | Customize..." menu
- Click on the "Tools" tab in the resulting dialog window
- Click the "New" button (this will add an item to the list)
- Rename the item to something like "Save Image"
- In the "Command" field type "wscript"
- In the "Arguments" field type the fully qualified path name of your 
javascript file (e.g. "c:\myscripts\saveimage.js")
- Leave the "Initial Directory" blank
- Select the "Prompt for arguments" checkbox
- Click on the "Close" button

Now whenever you want to save an image, just click on your "Save Image" menu 
item from the "Tools" menu. You will be prompted for arguments, with the fully 
qualified name of the script file already provided for you (e.g. 
c:\myscripts\saveimage.js"). Just add a space then the fully qualified path of 
where you want the image to be saved (e.g. "c:\myscripts\saveimage.js 
c:\myimages\abc.png").

The above is just an example, you can play with initial directories, etc. if 
you so desire.

For reference, trying to do the same in AFL did not work for me (version 5.26.5)

Trigger = ParamTrigger("Image", "Press to save image");

if (Trigger) {
        AB = CreateObject("Broker.Application");
        Win = AB.ActiveWindow;
        Win.ExportImage( "c:\\temp\\image2.png" );
}

Trying it as embedded jscript within the AFL didn't work either.

Mike

Reply via email to