Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a text file to a network printer using VB6 1

Status
Not open for further replies.

CruiseMan

Programmer
Nov 17, 2006
29
US
I have a PC running Win NT4 (sp6) that runs a VB6 procedure that sends a standard text file to a local printer (lpt1).

Shell "cmd /c type C:\MYFILE.TXT > LPT1"

My helpful hardware support group has replaced the local printer with a network printer and the text file no longer prints. I made sure that the new printer is set to the default printer. Other documents print (Word, Excel, etc.) but not the text file. Any input is appreciated.
 
Can you not use something like
Code:
... C:\MYFILE.TXT > \\network\printer\

If at first you don't succeed, then sky diving wasn't meant for you!
 
or just try this one ...

First you have to declare the API
Code:
Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" (ByVal hWnd As Long, _
    ByVal lOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long

And this should print the file to the default printer
Code:
ShellExecute Me.hWnd, "print", "path\filename", "", "", 1


Kind regards
Mirko
--------------------------------------
>>>>>> ... I am sure, some supportissues are a matter of PEBKAC ... <<<<<
 
@cruiseman: Any news here? Did you manage it somehow?

Kind regards
Mirko
--------------------------------------
>>>>>> ... I am sure, some supportissues are a matter of PEBKAC ... <<<<<
 
Thanks, Mirko. This API call worked like a charm, the text file is printing on command now. Much appreciated!

John
 
Or just use the Shell object:
Code:
    Const ssfDESKTOP = 0
    With CreateObject("Shell.Application").NameSpace(ssfDESKTOP)
        With .ParseName(FULLPATHOFTEXTFILE)
            .InvokeVerb "print"
        End With
    End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top