-
Solved: Run MODI from Excel
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:
[VBA] Public appWord as Word.Application
Sub MyRoutine
Set appWord = GetObject(,"Word.Application")
appWord.documents.open "MyDocument"
'do whatever
Set appWord=nothing
end sub
[/VBA]
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
-
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 level[VBA]Dim myDoc As MODI.Document
Set myDoc = New MODI.Document
myDoc.Create[/VBA]
K :-)
-
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:
[VBA]
Dim MyDoc As MODI.Document
Set MyDoc = New MODI.Document
MyDoc.Create (MyFile)
MyDoc.PrintOut copies:=NumCopies
[/VBA]
Printout also has an argument 'FitMode'. It makes no difference what value I put in. Can you help me fix this please?
Cheers
Chris
-
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.[VBA]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[/VBA]
K :-)
-
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.
[VBA] 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
[/VBA]
Help on MSDN and elsewhere seems quite limited/vague.
Cheers
Chris
-
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
K :-)
-
Shucks
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules