ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Print Command on a file (https://www.excelbanter.com/excel-programming/303439-print-command-file.html)

Spencer Hutton[_3_]

Print Command on a file
 
is there a way to execute the print command on a file from excel. liek if
you were to right click on a file and choose print from the shortcut menu.



Ron de Bruin

Print Command on a file
 
If the file is open you can use
http://www.rondebruin.nl/print.htm#Print


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Spencer Hutton" wrote in message ...
is there a way to execute the print command on a file from excel. liek if
you were to right click on a file and choose print from the shortcut menu.





John[_80_]

Print Command on a file
 
is there a way to execute the print command on a file from excel. liek if
you were to right click on a file and choose print from the shortcut menu.


This one works for me:

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

-- John

Ivan F Moala[_3_]

Print Command on a file
 
"Spencer Hutton" wrote in message ...
is there a way to execute the print command on a file from excel. liek if
you were to right click on a file and choose print from the shortcut menu.


To simulate this then amend this to your needs
This prints a word Doc....

Option Explicit

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_HIDE = 0
Private Const strFilePath As String = "C:\White Rose\Templates\WRS
Compliments Slips.doc"

Sub WordPrint()
Dim retVal As Long

retVal = ShellExecute(0, "Print", strFilePath, 0, 0, SW_HIDE)

If retVal < 32 Then
'// there are Error codes for this..left out
MsgBox "An Error occured...could not print"
End If

End Sub


All times are GMT +1. The time now is 12:14 PM.

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