View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tim C Tim C is offline
external usenet poster
 
Posts: 8
Default Print non-XL file

I found the code below at MSKB article 238245.
http://support.microsoft.com/default...45&Product=vba

I changed "open" to "print" and it works as required.

Thanks,
Tim C


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

Declare Function apiFindWindow Lib "User32" Alias "FindWindowA" _
(ByVal lpclassname As Any, ByVal lpCaption As Any) As Long

Global Const SW_SHOWNORMAL = 1

Sub ShellExecuteExample()
Dim hwnd
Dim StartDoc
hwnd = apiFindWindow("OPUSAPP", "0")

StartDoc = ShellExecute(hwnd, "open", "C:\My Documents\Book1.xls", "", _
"C:\", SW_SHOWNORMAL)
End Sub


"Tim C" wrote in message
...
XL 2K

How would I tell Windows to print a non-Excel file (say,

"c:\test\test.tif")
from within a macro?

Thanks,
Tim C