How to display a TIF image in Axapta

One of my ISV Buddies asked me how he could display a TIF file of a scanned invoice in Axapta. He needed to this in an approval workflow solution he’s building around vendor invoices.

Actually it’s pretty easy to do with one of the many ActiveX controls for displaying TIF files that can be found on the Internet.

We decided to look closer at the “Microsoft Office Document Imaging 2003 (MODI)” model.
This viewer ActiveX and the type library are included in Office 2003. The Visual Basic reference has more information on how to install it.

We made the following simple example for him to get him started.

When the ActiveX is installed, start up Axapta. In Axapta you should start by creating wrapper classes for the type library. Run the wizard from Tools \ Wizards \ COM Class Wrapper Wizard and select the “Microsoft Office Document Imaging 11.0 Type Library”.

Enter a suitable element mask. The names of the wrapper classes in Axapta will be prefixed with this element mask. In my example I’ve chosen “MODI”.

In the macro that is generated you go ahead and enter defines for the library. You don’t need to this now though to get on with the example.

Now create a new form, go to design, right click and select New control \ ActiveX.

In the ActiveX browser select the “Microsoft Office Document Imaging Viewer Control 11.0”.

All we need now is to add a little code to the form in order to load up a document.
public class FormRun extends ObjectRun
MODIDocument modiDocument;

Opening a document:
modiDocument = activeX.document();

Closing a document:

Printing to the default printer:

That’s all there is to it, but of course there’s still a bunch of features from the component that you can choose to implement in Axapta.
The object model is described in details on MSDN.