I am looking to print some text files locataed in my local drive, i tried everything i know to do that but no luck so far

Hope i can get a hand from here


Recommended Answers

All 4 Replies

plz state the problem much clearly. give some sample code which u have tried and failed. do u want to print the textfile content to a Dot Matrix Printer in DOS Mode? Do u want a formatted windows based output of the textfile content?


I am able to print now but I have a different situation, i need to print in landscape orientation instead of portrait

I am printing in text and I believe Notepad is the program that opens the reports by default

here is a sample of the code I am using and works fine


Public Declare Function apiShellExecute 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 Sub cmdPrint_Click()

Dim strFileAndPath As String
Dim lngReturn As String

strFileAndPath = "C:\Data\P139-C150-802-07-31-08.txt"

lngReturn = apiShellExecute(hWndAccessApp, "print", _
strFileAndPath, vbNullString, vbNullString, 0)

End Sub

As I explained above, this code works and i am printing my reports but the orientation needs to be changed to landscape

I found this code but not sure where to put it

Printer.orientation = acPRORLandscape

Thank you

As far as i know, u can open the printer properties and change the paper orientation to landscape manually.
Then if you try to print u will get the out in landscape itself.

Else otherwise use the Printer Object wherein u can manage all the printer settings. the code which u referred is the setting of the Printer Object which works if u print using the Printer Object.

For more details refer to.

Also a little information is attached in the Word file i have attached here

Also many articles regarding Visual Basic Techniques can be found here.


I have also attached a Word File extracted from the above website for a little reference of Printing in VB6

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.