954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Printing Text Files

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

Thanks

GTROYA
Newbie Poster
2 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

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?

aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

Thanks

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

Module:

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


Command:

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 itPrinter.orientation = acPRORLandscape

Thank you

GTROYA
Newbie Poster
2 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

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.
http://msdn.microsoft.com/en-us/library/aa267233(VS.60).aspx

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

Attachments Visual_Basic_Reference.doc (33.5KB)
aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

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

http://www.devarticles.com/c/a/Visual-Basic/

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

Attachments Printing_in_Visual_Basic.doc (48.5KB)
aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You