ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Print non-XL file (https://www.excelbanter.com/excel-programming/278541-print-non-xl-file.html)

Tim C

Print non-XL file
 
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



Tim C

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





All times are GMT +1. The time now is 02:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com