Thread: Print Text File
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steve Yandl[_3_] Steve Yandl[_3_] is offline
external usenet poster
 
Posts: 117
Default Print Text File

Charles,

The sub below will basically cause the text file to be printed in the same
fashion as if you right clicked it in Windows Explorer and chose 'Print'
from the context menu (or sent it into the printer). On my system, it
prints with Notepad.

'------------------------------------
Sub ShellPrint()

Dim strMyFile As String

strMyFile = "C:\Test\myList.txt"

Set myShell = CreateObject("Shell.Application")
myShell.ShellExecute strMyFile, , , "print", 0

Set myShell = Nothing
End Sub


'----------------------------------

Steve Yandl


'"vqthomf" wrote in message
...
Hi I have created a text file in vba and I need to print the file without
the
user opening it first, I have tried using excel import and print this
works
but cuts some of the text off. I was wondering if it can be printed by
send
the text file to the printer??.
Any help would be much appreciated.
Charles