0

The following vba routine works well to print a word document

        If sHlink <> "" Then
             Set OfficeObject = CreateObject("Word.Application")
             OfficeObject.Documents.Open sHlink
             OfficeObject.PrintOut Background:=False
             OfficeObject.Quit
             Set OfficeObject = Nothing
        End If

but what I need to print are .TIF documents. They open by default with the Microsoft Photo Viewer. Is there something similar that will call the MS Photo Viewer, or failing that, Acrobat? Perhaps with Acrobat could I use some kind of command line? Thank You

plh
  • 1
  • 2
  • Are they single-page TIF files or might they contain multiple pages? If single page, it'd be fairly simple and similar to automate PowerPoint to insert the TIF full slide size and then print. – Steve Rindsberg Aug 03 '13 at 20:48
  • Try ShellExecute with "print" as the verb; http://ss64.com/vb/shellexecute.html (or can be done with the win32 API) – Alex K. Aug 04 '13 at 12:22

1 Answers1

0

I found this shell command that prints using the Photo Editor that was formerly installed with Office:

Shell """C:\Program Files\Common Files\Microsoft Shared\PhotoEd\photoed.exe"" -p h:\misc\MyPicture.tif"

I think it can be adapted to print using the current Picture Manager - I bet it uses the same -p switch. This seems to be named "OIS.EXE" for some reason.

Andy G
  • 19,232
  • 5
  • 47
  • 69
  • Andy G, I have something like that adapted for VBA: dblRetVal = Shell(sDOSCMD, vbNormalFocus) where sDOSCMD is "C:\Program Files (x86)\Microsoft Office\Office14\OIS.EXE" -p 'G:\CITIZEN\MASTER\1) SETUP\DEPT_28\Process Drawings\EST1107REVSMETHODPRINT.tif' and dblRetVal returns a non-zero value (3712). but I get no print from the printer, any suggestions? – plh Aug 05 '13 at 20:31
  • You should first get the statement to execute from the commandline. Then the example code I posted indicates that the path to the application needs to be enclosed in quotation marks (by double-quoting each) because it includes spaces. You might need to do the same with the document path as I'm not sure that apostrophes will be parsed correctly. – Andy G Aug 05 '13 at 21:02
  • Thank you. Able to display but not print. I got it to display with sDOSCMD set to C:\Program Files (x86)\Microsoft Office\Office14\OIS.EXE "G:\CITIZEN\MASTER\EST.tif" Note that the command line is not enclosed by quotes but the file name is. However, -p must not be the print switch because placing it between, as in: C:\Program Files (x86)\Microsoft Office\Office14\OIS.EXE -p "G:\CITIZEN\MASTER\EST.tif" or at the end, as in: C:\Program Files (x86)\Microsoft Office\Office14\OIS.EXE "G:\CITIZEN\MASTER\EST.tif" -p neither one of those resulted in a print. – plh Aug 06 '13 at 18:25
  • I'm getting the impression that the Picture Manager doesn't support commandline arguments, Doh! I'll look into it a little further. Do you have another app installed that can print .tiffs? – Andy G Aug 06 '13 at 18:46
  • I'm thinking .pdf and use Acrobat reader. We are early in the process & I can tell the engineers, guys, you have to store those as .pdf files – plh Aug 06 '13 at 21:32
  • That might prove easier. I seem to recall now, a guy was having trouble previously when being emailed tiff files that displayed differently (different dimensions) in Word and elsewhere. – Andy G Aug 06 '13 at 21:44
  • Using .PDFs and Acrobat Reader is tuning out to be a cool breeze. – plh Aug 09 '13 at 16:14