This method uses notepad. It is possible to print using the DOS command window, but it gives problems if you use a network printer.
The code may need tweaking - might need full path references to Notepad, and change the Wait statement for a big file so there is plenty of time for this to happen before the next line of code tries to run.
Code:
Sub test()
Dim MyFile As String
Dim Enterkey As String
Dim Alt As String
Dim RetVal As Variant
'----------------------
MyFile = "C:\TEST.TXT"
Enterkey = "~"
Alt = "%"
'- open file in notepad
RetVal = Shell("notepad.exe" & " " & MyFile, vbNormalFocus)
If RetVal = 0 Then
MsgBox ("Problem opening Notepad.")
End
End If
'- send keystrokes to print
SendKeys Alt & "FP", True
'- wait 2 seconds for print to happen
Application.Wait Now + TimeValue("00:00:02")
'- close notepad
SendKeys Alt & "{F4}", True
End Sub
-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.