Print Text File

V

vqthomf

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
 
K

Karl E. Peterson

vqthomf said:
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??.

If you'd like to use whatever application the user has set to handle this sort of
request, it's as simple as this:

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

Public Function PrintDoc(ByVal DocFile As String) As Long
' Uses the "print" verb as defined in the registry
PrintDoc = ShellExecute(0&, "print", DocFile, vbNullString, vbNullString,
vbNormalFocus)
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top