PDA

View Full Version : Solved: Run MODI from Excel



chrismc
01-16-2006, 11:17 AM
Hi,

I can open Word documents and manipulate them using Excel VBA and I would like to do the same with Microsoft Document Imaging.

Simplified Code Excel Running Word:
Public appWord as Word.Application

Sub MyRoutine
Set appWord = GetObject(,"Word.Application")

appWord.documents.open "MyDocument"
'do whatever

Set appWord=nothing
end sub


What's the equivalent for running MODI from Excel please?

And yes I've referenced MODI and no I still can't work it out.

Thanks Chris

Killian
01-17-2006, 03:20 AM
Hi Chris,

If you've set a reference to the Microsoft Office Document Imaging type library, then you won't need to use late-binding as in the posted example. You should be able to declare objects directly.
If I understand its use correctly, you wouldn't create an instance of an application - it's effectively a print driver - so you can only work at document levelDim myDoc As MODI.Document

Set myDoc = New MODI.Document
myDoc.Create

chrismc
01-18-2006, 04:11 PM
Thanks, that's moved me forwards. I can now send a tif file to print. Unfortunately, the supposed A4 print actually comes out at 1 inch by 1.5 inches.

Here's the code:


Dim MyDoc As MODI.Document
Set MyDoc = New MODI.Document
MyDoc.Create (MyFile)
MyDoc.PrintOut copies:=NumCopies



Printout also has an argument 'FitMode'. It makes no difference what value I put in. Can you help me fix this please?

Cheers


Chris

Killian
01-19-2006, 03:44 AM
Well, I have to admit to knowing very little about MODI.
It seems a little strange that printout argument doesn't make any difference...
I'll investigate further, meanwhile, you could check the properties of the MODI document image, although I haven't worked out if scaling it is possible yet.Dim MyDoc As MODI.Document
Dim MyImg As MODI.Image

Set MyDoc = New MODI.Document
MyDoc.Create "c:\temp\test.tif"

Set MyImg = MyDoc.Images(0)
MsgBox "Image height = " & MyImg.PixelHeight & "px" & _
vbLf & "Image width = " & MyImg.PixelWidth & "px"

MyDoc.PrintOut copies:=1

Set MyImg = Nothing
Set MyDoc = Nothing

chrismc
01-21-2006, 02:23 PM
Killian,

Using your code I was able to get the following info:
Height: 2338 px
Width: 1653 px
plus with a little tweaking - DPI = 200.

The only thing about scaling that I've found is setscale which works with MiDocView. Can't get it to work.

Sub MyPrint()
Dim xx As Double, yy As Double
Dim MyDoc As MODI.Document
Dim MyView As New MODI.MiDocView
Set MyDoc = New MODI.Document

MyDoc.Create "H:\CAB\Handouts\Worklists Summary.tif"
MyView.Document = MyDoc
MyView.GetScale xx, yy
MsgBox xx ' Returns 1
MsgBox yy 'Returns 1
MyView.SetScale 6, 6 ' Increase 600% by 600%

MyView.GetScale xx, yy
MsgBox xx 'Still returns 1
MsgBox yy 'Still returns 1
'
MyDoc.PrintOut copies:=1, from:=1, to:=1 ' Still prints small

Set MyDoc = Nothing

End Sub


Help on MSDN and elsewhere seems quite limited/vague.

Cheers


Chris

Killian
01-23-2006, 05:32 AM
Well I'm somewhat stumped...
I had no problem printing a tif file with the code, until I made one with your dimesions, then it just didn't print at all !? I can suggest a couple of things at this point:
Test with a smaller image that physically fits on a page (I think the scaling is only for the viewer, rather than the image itself)
Try another printer/driver

chrismc
01-23-2006, 12:53 PM
Killian,

Thanks ever so much for looking at this. I have been working on this at home and at work so I've had the opportunity to try different printers with the same result.

I think it's time to change tack. I'm going to copy the pages from the .tif into a .doc and print that instead. If you (or anyone else looking in) have any more ideas I'll try them out.

Chris