Print .tif

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Print .tif

Post by agibsonsw »

Hello.

Is it possible to print a .tif file from VBA using the Picture Manager, or maybe another Windows tool?

I suggested to this guy to try:

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

but change it to point to "Office14\OIS.EXE" (the Picture Manager).

It's not working and I've been following-up; apparently the Picture Manager doesn't support command-line arguments and I feel obliged to pursue this a little further if possible.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Print .tif

Post by HansV »

The best I can do is this:

1) At the top of the module

Code: Select all

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
  ByVal hwnd As Long, _
  ByVal lpOperation As String, _
  ByVal lpFile As String, _
  ByVal lpParameters As String, _
  ByVal lpDirectory As String, _
  ByVal nShowCmd As Long) As Long

Private Const SW_SHOWNORMAL As Long = 1
The "print" routine:

Code: Select all

Sub PrintFile()
    Dim strFile As String
    strFile = "C:\Docs\MyFax.tif"
    If ShellExecute(0&, "Print", strFile, 0&, 0&, SW_SHOWNORMAL) < 33 Then
        MsgBox "Something went wrong", vbInformation
    End If
End Sub
When I run this (with the path+filename of an existing TIFF file), it displays the Windows 7 image print dialog. I still have to press Enter (SendKeys doesn't work).
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Print .tif

Post by agibsonsw »

Thank you Hans.

This presents me with an ethical dilemma though. I was pursuing this question, but you have provided a full answer (apart from the Enter bit :) ). I'm not comfortable copying and pasting this on another forum, in direct response to a question (rep points, etc.).

I have made use of the great information you have supplied in the recent past, but mainly to help me pursue, or verify, an answer, or to follow-up on something that intrigued me: not in direct answer to a question.

I wonder what your opinion, and others, are on such a subject?
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78524
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Print .tif

Post by HansV »

I'm not familiar with the rules of StackOverflow - do they object to posting a link to another board? If not, you could copy the code and post a link to this thread, or just post the link.
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Print .tif

Post by agibsonsw »

HansV wrote:I'm not familiar with the rules of StackOverflow - do they object to posting a link to another board? If not, you could copy the code and post a link to this thread, or just post the link.
SO is a pretty freaky environment :hairout: I think I might get told off. (Well, not told off, but.. you know what I mean.) I'll have to read over their rules tomorrow.

Off-topic. Challenging environment SO. You have to formulate a comprehensive, precise answer, but you can't take too long. The slightest mistake and it all gets negative.

Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.