Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Printing From Notepad ... **RESOLVED**


I know how to open Notepad and populate a file, from VB, but how do you print from Notepad via VB ?

I tried using SENDKEYS to do <ALT>F, then P, the carriage return, but that didn't seem to work.

Anyone any ideas ?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Printing To Notepad And Open With Results (Resolved)
I need a basic example to carry the results of a form to notepad and open notepad with the values passed.

If you could just give me an example of how to print "Hello World!" to Notepad and open Notepad after the value has been passed, then I think I can do the rest myself.

Your help will be appreciated.

Printing Desired Text Into Notepad....
This opens up the notepad file with my desired name, what I want to do next is have visual basic print text into the notepad file.


Code:
Dim dTaskID As Double, path As String, file As String
path = "C:WINDOWS
otepad.exe"
file = "C:Team Template.dat"
dTaskID = Shell(path + " " + file, vbNormalFocus)
End


Basically, I have a simulation sports game that uses modifiers read from a .dat file that are read as variables after being opened and used in a serious of dice rolls and equations.

I want to provide a way for players to create their own teams (.dat files) and the text that will show up in the notepad file will be a guideline of what information they need to provide.

Ideally, a notepad opens up with this printed:
Team Name,0,0,0,image.bmp


Thanks in advance, I don't start my game and simulation degree until this summer and I've only got 3+ years of self taught VB knowledge.

Printing Values From Notepad To The Printer
hi i was wondering if someone can help me out. i wanted to print the values stored in the notepad file to the printer when i hit the command button. thx

Private Sub cmdlabel_Click()
Open "database.txt" For Output As #1
Print #1, txtnamest
Print #1, txtaddressst
Print #1, txtaddressst1
Print #1, txtcityst, txtstatest, txtzipcodest
Print #1, txtcountryst
Close #1
End Sub

:Please Help Me Out: Printing # Records On A Page From RTB And Notepad
Hello,

Just read the Printing WSYIWYG by Hack. Nice one

But this will print continuosly the way text is shown in RTB, not matter if some text of a particluar point in a list goes to the next page.

If I want to print 15 Gate Pass, 3 on each page, do I have to manually get the number of lines the printer prints on a particular type of page (could be A4 or A3) and set my text with blank lines added accordingly to the RTB and give the print command so that I could get the desired result.


Code:
Head of GP
xxxxxxxxxxxxxxx[some text here]xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx[some text here]xxxxxxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxx[some text here]xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx[some text here]xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxx[some text here]xxxxxxxxxxxxxxxxxxxxxx

Name:_________ Date:_________ Sig:__________
If i use Hack's method, there is a possibility that some lines of a single pass could go to the next page which I don't want.

Also, how can I implement above WYSIWYG printing example to print text in a notepad file?

I hope I have explained!!

Thank you.

Printing Encrypted Text To Notepad
I am coding settings for my program and it will load the settings on program load and save the settings on program close. Some of these are encrypted and decrypted and thats what I am having a problem with.

Declarations:
Code:
Private TheLines() As String
Private FileContents As String
Private File As Integer


Encryption:
Code:
Public Function Encrypt(Text As String) As String
Dim I As Integer
Dim C As Integer
Dim Temp As String
Temp = ""
For I = 1 To Len(Text)
C = Asc(Mid(Text, I, 1))
C = C + 10
If C > 255 Then C = C - 255
Temp = Temp & Chr(C)
Next I
Scramble = Temp
End Function

Public Function Decrypt(Text As String) As String
Dim I As Integer
Dim C As Integer
Dim Temp As String
Temp = ""
For I = 1 To Len(Text)
C = Asc(Mid(Text, I, 1))
C = C - 10
If C < 0 Then C = 256 + C
Temp = Temp & Chr(C)
Next I
UnScramble = Temp
End Function


Settings:
Code:
Public Function SaveSetting()
Open App.Path & "Settings.txt" For Output As #File
Print #File, Form2.Option1.Value
Print #File, Form2.Option2.Value
Print #File, Form2.Option3.Value
Print #File, Form2.Check1.Value
Print #File, Encrypt(Form2.Text1.Text)
Print #File, Form2.Check2.Value
Print #File, Encrypt(Form2.List1.Text)
Print #File, Encrypt(Form2.Text2.Text)
Close #File
End Function

Public Function GetSetting()
Open App.Path & "Settings.txt" For Input As #File
Form2.Option1.Value = TheLines(20)
Form2.Option2.Value = TheLines(21)
Form2.Option3.Value = TheLines(22)
Form2.Check1.Value = TheLines(23)
Form2.Text1.Text = Decrypt(TheLines(24))
Form2.Check2.Value = TheLines(25)
Form2.List1.Text = Decrypt(TheLines(26))
Form2.Text2.Text = Decrypt(TheLines(27))
Close #File


When I run my program, I then try and add some settings. When I close the program I look at the text file which has been created and it has not added the encrypted text. I don't know why it is not printing it.






Edited by - Rapidfire on 5/7/2007 9:28:25 AM

* RESOLVED * Notepad Vs. Wordpad
You know how you can open a file in Notepad and it will display those square characters that are supposed to be carriage returns? Well Wordpad properly formats these characters. However, when I try to open this type of file as Input in Visual Basic, it doesn't recognize those characters just like Notepad. I'd like my Input statement to act like Wordpad does and recognize those special characters. Anyone know how to do that?
Here's the code:

VB Code:
Open .FileName For Input As #1Do While Not EOF(1)Input #1, lineArray(i)   i = i + 1Loop

Notepad Shell [Resolved!]
Why wont it launch that text file with the notepad shell?

Printing Individual Array Elements In A Notepad
Dim fname As String
Dim i As Integer
fname = "C:mycodef.txt"
Open fname For Input As #1
While Not EOF(1)
Line Input #1, Mystring
'MsgBox Mystring
Myarray = Split(Mystring, ",")
For i = 0 To UBound(Myarray)
MsgBox Myarray(i)
Next i
Wend
Close #1
End Sub

result of above code is splitting of the entire string into subelements
MA,HINGHAM,02043,PLYMOUTH,HING-000090-000000-000013,26,ABERDEEN,RD,(1-101 ABERDEEN RD)

now if i want to print individual elements seperated by commas .how do i print the individual array elemnts in a different order
FOR EXAMPLE ITHE ABOVE DATA CAN BE PRINTED AS

, ,HINGHAM,02043,MA, ABERDEEN AND SO ON.......

INSHORT HOW DO I CAPTURE INDIVIDUAL ARRAY ELEMNTS IN A STRING TO PRINT IT TO A NEW .TXT FILE
_________________________________________________________________
Private Sub Print_Click()
MsgBox Mystring
'Dim dumb As String
'Dim fname As String
'fname = "C:mycode
eformat.txt"
'Open fname For Output As #2
'dumb = create_command_string(1)
' Print #2, dumb
'Close #2
End Sub

Writing Text To Notepad (Resolved)
Hi Team

Does anyone know how to write directly to Notepad. I want to output the results of a search directly to the screen in a form that the user can then either print or save. I don't want to create a text file and then display it. Rather, I want to create an instance of Notepad and then write to it.

This is what I have so far!
VB Code:
Option ExplicitPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate lngNotepadHandle As LongConst WM_SETTEXT As Long = &HC    Friend Sub PrintLine(Line As String)    Dim hEdit As Long        hEdit = FindWindowEx(lngNotepadHandle, 0&, "Edit", vbNullString)    SendMessage hEdit, WM_SETTEXT, 0&, ByVal LineEnd Sub Friend Sub CreateNotepad()    Shell "notepad", vbNormalFocus    lngNotepadHandle = FindWindow("notepad", vbNullString)End Sub

Calling CreateNotepad creates an instance of Notepad and PrintLine outputs a line. But each call of PrintLine replaces any existing Notepad text with the Line. Does anyone know how to change the PrintLine function so that it will append to the existing text rather than replacing existing text?

Thanks

FW

Opening A NotePad File ***RESOLVED***
The following opens NotePad but I get a message that it can't find the file. I did a debug.print on the App.Path and I know I'm in the correct directory where the file is located. Also, the *.log file name is correct. Any ideas what's going on?
VB Code:
Shell "NOTEPAD.EXE & App.Path & MachineTenderPM10_error.log", vbMaximizedFocus

Opening/Running Notepad (Resolved!)
I have a txt file that I want to open in my vb program using Notepad.

The only problem is that I don't know how.

I don't want to copy the details in a rtf, I just want to run Notepad.

I have looked around for help and the only suggestion is that I "shell" Notepad.

What is shell - is this the only way?

I am tired and confused - Please help!!!



"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."
Albert Einstein (1879 - 1955)

Edited by - thajaguare on 11/30/2004 6:07:11 AM

Notepad Inside The Form? ##RESOLVED##
HI!
Is there some way to open notepad inside the program and not like:
Code:Shell ("notepad C: extdocument.txt")

lets say I have in form some buttons at top of the form, and at the bottom I have this textbox, or notepad, that will open the textfile. Eery button will open different textfile in that textbox/notepad.

Thanks!!!



Edited by - DDDD on 7/26/2003 2:46:45 AM

.:RESOLVED:.Saving Notepad File To A Location
I have a program that Shells out to notepad, then uses Sendkeys to send some text to the notepad window. Now what I want it to do is save the notepad file to a specific location on the hard drive. How can I tell notepad to save it to a certain location when it's a new notepad file? I'm sorry if this is confusing, I'm just not sure if this can be done or not.

Thanks,

Remember that this world is not reality. It's a playground of appearances on which we practice overcoming seems-to-be with our knowledge of what is.
ViRuaL

Edited by - ViRuaL on 9/15/2005 5:26:47 PM

How To Save And Load Information To And From A Simple Notepad File. &lt;&lt;RESOLVED&gt;&gt;
Hello everyone and thanks for the help ahead of time. This is my very first post, so it might not be up to your standards yet.
But I'll Try!

I have been reading Visual Basic 6 for Dummies, (I know this is not the best source of info) but have recently lost the book. While reading it, I saw a piece of code describing how information from variables or strings (ie. text boxes, labels, and other variables) can be recorded or read from a Windows Notepad file(*.txt). At the time, I didn't think I would need it. Now that the book has been lost, I actually do need this information. I have looked at some of the other self-help sites and they are to advanced for my knowledge. I am obviously still very Newbie. If anyone can Explain it to me and/or possibly supply a Snippet of Code, I would greatly appreciate it.
Again thanks for the help.



If ever you need me, just look to the sky and shout my name.
~The Cloudman~


Edited by - The Cloudman on 5/25/2004 5:18:02 AM

Copy All Text From Textbox, Open Notepad, And Automatically Paste To New Notepad Shee
Hello everyone.

I am trying to copy all text, that is already in the textbox, to a new notepad sheet.

Example:

Step 1. Copy all text in Text1 box to clipboard.
Step 2. Open Notepad
Step 3. Paste clipboard to notepad.

All this should be done with one click of a button.

I get as far as copying everything to the clipboard, and it even opens up notepad, but I still have to manually paste (CTRL-V) into notepad.

I would even like it to ask me what name to save it as as well as where to save it at...just like the Save As function in Word or something.

Here is what I have so far.

Private Sub cmdCopytoClipboard_Click()
Dim MyAppID
Clipboard.Clear
Clipboard.SetText Text1.Text
MyAppID = Shell("NOTEPAD.EXE", 1)
AppActivate MyAppID
MyAppID = Clipboard.GetText()


End Sub

Notepad To Access,Grid And Back To Notepad
Hi,
i hav a notepad where there are many lines stored in it.
i need it to separate it as each word(; as separtor).
actually there are 50 columns in Access as backend with various datatypes(49 for data and 1 for end of file........two boxes).
so after 50 countings are identified, it is considered as first record. and then data for second record starts.
after saving to the backend Access, i need to view the content in DataGrid(VB6) where editing of records is permitted.so after editing and while saving it to Access,i need the change to be reflected in Notepad also(with the same format as ; as separator between records and two boxes for end of record).
Plz help me to solve this...............its really urgent!!!

NOTE: Attached one.txt for sample and the backend Access table.

How Does Notepad.exe Creates Notepad.txt?
a simple question..just to know.
how does notepad.exe creates notepad.txt?
is there anything to consider?

-thanks

** RESOLVED ** Printing Using CommonDialog
I am having a senior moment, I think. Here is the deal... A User has 2 printers in their control panel; PrinterA and PrinterB. They have PrinterA set as their default printer. For this report, they want to print to PrinterB. I want the report to go to printerB, but I don't want PrinterB to become their default printer. I used the following code and the printing was sent to PrinterA:


VB Code:
Dim PRINTREPLY As StringPRINTREPLY = MsgBox("Print to screen?", vbYesNo)If PRINTREPLY = vbNo Then    glbPrinterDestination = 1    CommonDialog1.ShowPrinter    CommonDialog1.PrinterDefault = vbFalseElse    glbPrinterDestination = 0End If'Set Report = crxApplication.OpenReport("Z:DADEmpCalendarDetails.rpt", 1)For Each crxDatabaseTable In Report.Database.Tables    crxDatabaseTable.ConnectionProperties("user id") = "sa"    crxDatabaseTable.ConnectionProperties("Password") = myPasswordTechniSQLNext crxDatabaseTableReport.SelectPrinter glbPrinterDriver, glbPrinterName, glbPrinterPortReport.PaperOrientation = crDefaultPaperOrientationIf glbPrinterDestination = 0 Then    glbReportForm = "frmCalendarDetails"    CRViewer.Show 1Else    Report.PrintOut FalseEnd If


This line is the issue, I think

"CommonDialog1.PrinterDefault = vbFalse"

If I leave that in, the report prints to PrinterA (even though they select printerB). If I comment it out, the report goes to PrinterB, but now PrinterB is their default printer.


I'm ready to smack my forhead and say "d'oh" when someone points out my problem.





Added green "resolved" checkmark - Hack

Printing Reports(Resolved)
hi,

I only can print the report once. If i print for the second time i have the run time errors " Operation is not allowed when the object is open. What can i do to avoid this. How to use refresh here?


Private Sub Print_Click()

DataEnvironment.Invoice_Grouping reg_no, inv_no
Invoice.Show vbModal

End Sub

Printing A Form In Vb - RESOLVED
helo;

i want to have a print button on a form to automatically print the present form on the screen. I dont know how i could do this. Are there any suggestions on how this could be done?

Printing Positioning (RESOLVED)
Hi,

I have the following code that reads in and print the specified file.

what are the commands to put some text in a specified positions?

Thanks

Loftty


VB Code:
Set objWordApp = CreateObject("Word.Application")objWordApp.Visible = FalseSet objDestDoc = objWordApp.Documents.Add Set objWordDoc = objWordApp.Documents.Open("C:Documents and SettingsBen RichesDesktopVB6 estdelete estlistnew estlabels.doc") Set objDestRng = objDestDoc.Content  objDestRng.DeleteobjDestDoc.PrintOutobjDestDoc.Close SaveChanges:=FalseSet objDestDoc = NothingSet objWordDoc = NothingobjWordApp.QuitSet objWordApp = Nothing

***Resolved****printing Within VB6 Using App Crviewer
I have a number of reports in my vb6 app. I'm using Crystal version 8.5 dev. When the user views the report I want him to be able to print it from within VB6 app. When I click the Print button on the viewer it shows a window with my default printer which is what I want it to do but when I then click ok nothing happens at all. However if I pull up the same report outside of the vb app. The print button works just fine it shows my default printer then clicking ok it sends the report to the printer. Any idea as to what I need to do to make it work ??

Thanks for any help

Printing To File (*Resolved*)
Ok, I have created a form and can have all the little textboxes on the form print to a file in a nice fashionable way. I am currently using "Print" to print the strings to file. I have also used "write", but it didn't really help mch.. anyway.... I was wondering if there was any way (other than putting all of the things on one infinite 'print' line) that I could print items withough line breaks in between. I read in files as comma delimited, so line breaks would cause a problem. If there is a solution, please let me know what it is. If not... let me know that I am attempting the impossible. THanks,

Amy



Edited by - magum on 11/30/2004 6:41:01 PM

Printing A Listview&lt;RESOLVED&gt;
I hate listviews (but love them at the same time) why are they so complicated!
How do you print a listview
plz help quick. Thx



Edited by - chuckury on 9/14/2003 11:31:07 AM

Printing From A .prn-File ***Resolved***
It's very easy to send the output from a printer to a file. But it seems impossible to send this file back to a printer.
After finding no way in VB, I tried it via SHELL-command and the 'good old' DOS-copy-command ( "c:command.com /c copy " & strFile & " prn:" )
Ten years ago, this was working well. But if the printer isn't connected to a printerport but is a network-printer then i only get the message: 'device not ready'.

Is the possibility of printing into a file only a useless archeological remain? Or does anybody know a solution for this problem ?



Edited by - Ken Twin on 12/15/2004 4:22:26 AM

Printing Reports Resolved
hey.
Im working on a vb application that works off an Access database.One of its functions is to do calculatons on the data in Access and generate a report on it.Currently the report is generated by performing the calculations on the data,then adding the result to a listbox, and Im doing this in a loop until Ive run through the relevant data.This works fine.
Im wondering if I want to use the data generated,is there a way I can copy my data from my VB list and paste in somewhere,ie into a column of an excel document.
Thanks.



Edited by - star84 on 6/23/2004 4:06:56 AM

***RESOLVED***Printing Pdf's From ListView Control
I have a ListView control which lists 460 file names. For each of the 460 file names, in the Listview control, a corresponding pdf document of that exact name exists in a specified folder on the network. I have a command button, as well, which is supposed to allow the user to print all of the 460 files listed in the ListView control. The command button event procedure:

1) grabs the first file name from the ListView control
2) verifies the file exists in the directory
3) prints the file if it exists
4) moves to next file in the ListView control and repeats steps 1-3

The problem I am experiencing is that when the button is clicked, anywhere between 40-60 of the files from the ListView are printed (as opposed to the 460 which shoulld be printed). I receive no error message, it just simply stops printing.

Any examples to do this or suggestions greatly appreciated.

thx

Printing Web Page At WebBrowser {Resolved By Myself}
Hi, there!

I need to print a webpage opened at a WebBrowser component... How can I do that ?

[]s,

Joćo Luiz

Automated Text Printing (Resolved)
I apologize for my first post here being a question, new to VB, have a specific need and this forum seems to have a wealth of information. I searched the forums and many other places but could not find what I needed so here goes.

I need to create 3 apps to print data from a text file. The file only contains 10 lines total, 5 of those are data, other 5 are blank lines. The output is to a DataMax Label printer. There are 3 of these printers installed in the Windows environment. I will need to hardcode the destination printer into each of the scripts. Win printer names are dmax_3, dmax_4 and dmax_5.

This is an industrial project using scripting from software written by GE, included in their HMI package. I can't send output directly to a printer from their software but I can create a formatted text file and activate an external application, the VB script passing to it the file name for printing. This name will always be the same for each script.

I need this to happen completely hands off and in the background with no user input whatsoever.

This would seem to be an easy task, but so far I am really struggling. Can anyone here help?

Thanks In Advance,
Ricky Kicklighter

&lt;resolved&gt; Printing A Multiline Textbox
Hello guys
I am printing a multiline textbox (let's say 3 lines of text) with the following code:
'------------
printer.currentX=1000
Printer.CurrentY =1000
printer.print txtMyNotes.text
'-----------
As you might guess the first line will be printed on the (1000,1000) coordinates but the second line of text will be printer at start of the next line (Something like 0,1100) !
How can I make sure the other lines of multiline text are alligned same as the first line in one bulk?
Thanks
SW
PS. The data in the multiline textbox is coming frm an Access 2000 database.

Example Of Printing A Crystal Report **Resolved**
I've never sent a report to a printer from Visual Basic before. What I want to do is create a project that will run nightly via the windows scheduler , run a crystal report, and have it sitting on someone's printer in the morning.

I'm doing the research but a working example of sending a report to a printer would be helpful.

I've searched the forum but didn't find anything.

Thanks!

**RESOLVED** Center MSchart When Printing??
I have the following code in which I need to find a way to center the chart on the paper when printing:

VB Code:
Printer.Orientation = 2             'Print Landscape              Printer.PrintQuality = vbPRPQHigh   'Print quality = high                                      frmRepChart.PhoneChart.EditCopy 'copies a picture of the chart (meta file format) and the chart data to the clipboard                                   'adjust the coordinates to suit your needs               Printer.PaintPicture Clipboard.GetData(vbCFMetafile), 0, 0, frmRepChart.PhoneChart.Width, frmRepChart.PhoneChart.Height                                    Printer.Print                Printer.FontBold = True                Printer.FontSize = 12                Printer.FontUnderline = True                Printer.Print Tab(20); "CPMS Representative Trend Report"                Printer.Print                Printer.Print ""                Printer.Print ""                Printer.Print ""                Printer.Print ""                Printer.Print ""                Printer.Print ""                                    Printer.EndDoc 'sends the chart to the printer                                    Clipboard.Clear
The result of the above code is the Chart is placed at the top of the page...even with the title the chart overrides that and stays on top...

Any suggestions will be appreciated!!!

Thank you!

Printing Inside A Picbox [ RESOLVED ]
I have a form that contians a picbox and a Sub that prints inside the picbox. If i call the sub with a command click (a button) it works just fin (the picbox is filled with the info).. but if i call the sub in the Form_Load event it doesn't work.. why?

anyone?

*RESOLVED* Simple Printing Problems
Questions regarding the 'Pinter' object...

(1) How do I adjust the left margin? My printer prints the data directly to the margin of the paper which is kinda ugly. How do I tell it to move all lines just 2 cm longer to the left?

(2) How do I make a horizontal line without using coordinates and crap? I want to just print a line after the text i just printed (the text varies in lenght, whish rules out specific coordinates)?

Thank you in advance

Printing With The RIchTextBox Control &lt;Resolved&gt;
Greets,

I have seen this code
Code:
Public Function PrintRTF(rtb As RichTextBox, _
                         Optional PrinterDC As Long = 0, _
                         Optional LeftMargin As Long = 1440, _
                         Optional TopMargin As Long = 1440, _
                         Optional RightMargin As Long = 1440, _
                         Optional BottomMargin As Long = 1440) ' <== Set Margins here

  Dim i As Long, prn As Object

  If (PrinterDC = 0) Then
    ' use the default printer

    PrintRTFText Printer, rtb, LeftMargin, TopMargin, RightMargin, _
        BottomMargin, False
    Printer.EndDoc

  Else
    ' search for printer
    For i = 0 To Printers.Count - 1
      If Printers(i).hdc = PrinterDC Then
        Set prn = Printers(i)
        PrintRTFText prn, rtb, LeftMargin, TopMargin, RightMargin, _
            BottomMargin, False
        prn.EndDoc
        Exit For
      End If
    Next i
  End If
End Function


several times on VBCity, but there is never any mention on how to get the function to work. When I try to use this function by stating:
Code:
printrtf(RichTextBox1,0,288,288,288,288)


Where "RichTextBox1" is the rich text control on the form, 0 should just the be default printer, and all the 288's are supposed to be the margins, all I get is an error message "Compile Error: Expected: ="

Could someone explain what I'm missing?

Thanks



Edited by - Runescope on 11/18/2005 1:07:08 PM

Printing Contents Of A Textbox (RESOLVED)
My problem concerns printing the contents of a textbox.
When the user of my program types text into a textbox, The contents are printed as part of a report, the textbox contents print but when the text reaches the righthand edge of the page the text just disapears off the edge of the page and does not continue on the next line.
I've tried just about everything i can think of but nothing works.
Hope someone out there can help.

SKM.



Edited by - SKM on 12/31/2004 3:43:53 AM

Printing Contents Of A ListBox (RESOLVED)
Got a question here about Printing the contents of a ListBox.
On my Form I have a ListBox from which I need to print out the ListBox contents, it sounds simple but how do I get it to print across multiple pages, ie page break after say 50 lines.
What I need is to count the number of items in the listbox, then print about 50 on the first page, then print 50 on the next page untill all items are printed.

Cheers.

 

Edited by - SKM on 12/31/2004 3:37:36 AM

DataGrid Printing Header {Not Resolved}
Hello All members
How can i print the content of the DataGrid as Report with the showing the datagrid header?
Thanks alot for advice

Egyptian Man

Edited by - khaledagwa on 11/9/2004 2:15:27 AM

*** Resolved *** Using Datareport Designer For Printing
I have a program that connects to an access DB created with access 2002 SP-1. I am using VB 6.0 for 32 bit Windows development. When I use the MSDN tutorials on creating reports with the data report designer it tells me to use the Microsoft Jet 3.51 OLE DB Provider in the Data Link Properties to connect with the Northwind database. All of this works fine and I can create everything the tutorial tells me to do.

However, when I try to use this knowledge to create my reports with my Access DB for my project I have to use a different Jet provider. Instead of the 3.51 I have to use the Jet 4.0 Provider to connect. I have tested the connection and it does work.

My problem is this: I have three tables that I need to pull data from for this report. But I can only drag and drop fields from one of the tables onto the form. I have followed all of the tutorial instructions for adding the other tables but nothing seems to work.

If anyone has experience with this can you clue me in? I know this isn't a whole lot to go by but this whole part with the designers is new to me and it is not coming very easy.

Thanks for any help given. Later,



Cliff R.
Mesa, AZ
Check out my website at http://crogers.org
Being an organ donor is giving the greatest gift that someone can give.
It is giving the gift of life. Please register to be an organ donor.


Edited by - crogers on 9/12/2005 10:24:03 AM

*** RESOLVED***Printing A Report From My VB Program
Hi everyone, I have a program that stores reservations made by residents for their medical transportation needs. Each day the drivers,or the boss, will need to print out a report for that day's transportation. I am creating this as a stand-alone program and I don't have crystal reports or anything like that to bundle with this program. I have created a separate form with a picture box on it where I can display my report on. How do I do the following:

1. How do I use the scrollbars to be able to move the displayed data up/down and left/right for viewing before printing?

2. How do I send what is displayed in the pic. box to the printer so that it prints out looking the same as what is on the screen.
      I mean that the report will fit completely on one page of paper even though it won't completely be visible on a monitor.

3. I can display my data in the format I want it to be shown in using the extended listview from Visual Creations. Can I print directly from that control? If so how would I do that?

Any help that can be offered will be greatly appreciated. Getting the printing worked out is, I think, my last major hurdle to completing my project.

Thanks,


Cliff R.
Mesa, AZ
Check out my website at http://crogers.org
Being an organ donor is giving the greatest gift that someone can give.
It is giving the gift of life. Please register to be an organ donor.


Edited by - crogers on 8/30/2005 11:48:57 AM

Word Printing List **RESOLVED**
Dear VBers,

I was wondering whether there is any sites that provides all the commands available for printing with Word using VB. Or whether Word has this function to list out the list. Please provide guidance.

Thx in advance!

Regards,
marsulein



Edited by - marsulein on 4/14/2004 7:53:26 PM

Print Quality When Printing Mschart *RESOLVED*
Hi All,

I there any way to improve the print quality when printing an mschart.

I use the following code to pritnt the chart (via the clipboard).
The resulting quality is very poor.


VB Code:
Printer.Orientation = 2             'Print Landscape    Printer.PrintQuality = vbPRPQHigh   'Print quality = high    chtPower.EditCopy    Printer.Print Tab(40); labPowerCurveStats.Caption    Printer.Print ""    Printer.Print ""    Printer.Print ""    Printer.PaintPicture Clipboard.GetData(), 0, 1000, Printer.Width - 1000, Printer.Height - 1000    Printer.EndDoc


Any suggestions as to how to produce a higher quality, more professional looking printout would be appreciated.

URGENT Fix Display In When Printing In A PictureBox [ RESOLVED ]
Hi im printing in a picbox, when in run my app in my computer the text i printed in the picbox siplays just fine; but when i install my app in another computer (same OS) the display move all around and makes a mess .. how can ia make a diplay that displays correctly in any pc in install it?

plas, its urgent! thx

Problems Printing Picture Box - **Resolved (kinda)**
I found this code on the board to print the contents of a picturebox (controls) as an image on the picture box and then print the picture box.


VB Code:
Option Explicit Private Declare Function SendMessage _        Lib "user32.dll" Alias "SendMessageA" _        (ByVal hwnd As Long, _        ByVal wMsg As Long, _        ByVal wParam As Long, _        ByVal lParam As Long) As Long Private Const WM_PAINT = &HFPrivate Const WM_PRINT = &H317Private Const PRF_CLIENT = &H4&     ' Draw the window's client areaPrivate Const PRF_CHILDREN = &H10&  ' Draw all visible childPrivate Const PRF_OWNED = &H20&     ' Draw all owned windows  Public Sub PrintPictureBox(Box As PictureBox, _        Optional X As Single = 0, _        Optional Y As Single = 0)    Dim rv As Long    Dim ar As Boolean        On Error GoTo ErrHandler        With Box        'Save ReDraw value        ar = .AutoRedraw                'Set persistance        .AutoRedraw = True                'Wake up printer        Printer.Print                'Draw controls to picture box        rv = SendMessage(.hwnd, WM_PAINT, .hDC, 0)        rv = SendMessage(.hwnd, WM_PRINT, .hDC, _        PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED)                'Refresh image to picture property        .Picture = .Image                'SavePicture .Image, App.Path & " emplatesimage.bmp"        'SavePicture .Picture, App.Path & " emplatespicture.bmp"                'Copy picture to Printer        Printer.PaintPicture .Picture, X, Y        Printer.EndDoc                'Restore backcolor (Re-load picture if picture was used)        Box.Line (0, 0)-(.ScaleWidth, .ScaleHeight), .BackColor, BF                'Restore ReDraw        .AutoRedraw = ar    End With Exit SubErrHandler:    If Err.Number Then        MsgBox Err.Description, vbOKOnly, "Printer Error!"    End IfEnd Sub


It works great, except with my custom controls I created. They do not show up in the printed image.

The custom controls are very simple controls; a usercontrol with 2 rich text boxes and a shape control. Anybody have any ideas why that wouldn't print?

Thanks in advance . . .

*Resolved* Freakazoidian Printing, Can Only Print Something Once Succesfully
ok, got some code here which is acting up a bit. The "Printer.Print Chr(10) & "Verslag van de wedstrijd van: " & sListText" does get printed the first time I print after booting up the program, but after that, it just gets left out. Also the printing starts right at the top of the page, which shouldn't happen becuase of this: " Printer.ScaleTop = 1440". So, all in all that's kinda weird. No other part of the program does anything with the printer.
I've got a HP 5550. So, does anyone have a clue as to why this could be happnin'?

VB Code:
Private Sub WedstrAfdrukken()  'prints the information on the selected wedstrijd'  Dim rsRecSet As New ADODB.Recordset  Dim sListText As String  Dim sVerslagText As String  Const PAGELENGTH As Integer = 100   'make the printed text start some space from the edge of the page'  Printer.ScaleLeft = -800  Printer.ScaleTop = 1440      sListText = lstWedstrijden.List(lstWedstrijden.ListIndex)     Call modWedstrijdData.DBRead("SELECT * FROM tblWedstrijden, tblDuiven_In_Wedstrijd" & _"WHERE tblWedstrijden.Wedstrijd_Datum = tblDuiven_In_Wedstrijd.Wedstrijd_datum AND " &_tblWedstrijden.Wedstrijd_Datum = '" & sListText & "';", rsRecSet)     'print the general wedstrijd data using the printer object'    rsRecSet.MoveFirst    Printer.FontName = "Garamond"    Printer.FontSize = 14    Printer.FontBold = True    Printer.FontUnderline = True    Printer.Print Chr(10) & "Verslag van de wedstrijd van: " & sListText     Printer.FontSize = 12    Printer.FontBold = False    Printer.FontUnderline = False '......jadajada, printing stuff, jadajada...'      'add the programs name at the bottom'    Printer.FontSize = 8    Printer.Print Chr(10) & "Dit verslag is gemaakt met " & App.Title    Printer.EndDoc  End If   rsRecSet.Close  Set rsRecSet = Nothingend sub

*RESOLVED* Printing Contents Of A Textbox On A Picture
Hello Everyone,

I have 2 picture boxes Picture2 inside Picture1 so I can scroll the
picture. I have a .bmp in Picture2 with several textboxes for
order entry. I would like to allow the user to print out the picture to place in a file. I know how to print a picture and I know how to print text, but how can I print out the text on top of the picture?



Thanks in advance

RESOLVED: Blank Pages When Printing Flexgrid
Found a solution. Deleted msfTemp and created copy of Grid1 named msfTemp. Worked fine.


I found some great code to help me with the printing of flexgrids, which I incorporated in a user object I am working on in a subroutine:


VB Code:
Dim msfGrid As MSFlexGrid    Dim c, r, p, iRowsPerPage, iPages As Integer    Dim toprow, bottomrow, x As Integer         Set msfGrid = Grid1     iRowsPerPage = 55 'number of rows per page        msfTemp.Clear        msfTemp.FixedCols = 0    msfTemp.FixedRows = 1    msfTemp.Cols = msfGrid.Cols    msfTemp.Rows = iRowsPerPage    msfTemp.FormatString = Grid1.FormatString     If msfGrid.Rows Mod iRowsPerPage = 0 Then        iPages = msfGrid.Rows / iRowsPerPage    Else        iPages = msfGrid.Rows / iRowsPerPage + 1    End If     For c = 0 To msfGrid.Cols - 1        msfTemp.ColWidth(c) = msfGrid.ColWidth(c)    Next c     msfTemp.Width = Printer.Width     If msfGrid.Rows < iRowsPerPage Then        bottomrow = msfGrid.Rows    Else        bottomrow = iRowsPerPage - 1    End If        toprow = 1        For p = 1 To iPages            'Headers            For c = 0 To msfGrid.Cols - 1                msfTemp.TextMatrix(0, c) = msfGrid.TextMatrix(0, c)            Next c        '    r = r + 1        'End If        x = 1         For r = toprow To bottomrow            For c = 0 To msfGrid.Cols - 1                msfTemp.TextMatrix(x, c) = _                    msfGrid.TextMatrix(r, c)            Next c            x = x + 1        Next r         Printer.PaintPicture msfTemp.Picture, 100, 100                   Printer.NewPage            toprow = bottomrow + 1        bottomrow = toprow + iRowsPerPage - 2        If msfGrid.Rows < bottomrow Then _           bottomrow = msfGrid.Rows - 1        Next p     Printer.EndDoc     Set msfGrid = Nothing


I get blank pages trying to print from msfTemp. If is a flexgrid that I have placed behind Grid1 (which is my main grid).

If I print from Grid1, I get at least something, but I am trying to format for a specific number of lines on the page.

I am a relative newbie, and any suggestions are greatly appreciated.

Donna

Printing A RichTextBox NOT Using A ComCtrl Dialog ** RESOLVED **
Ok, here's my code:


VB Code:
Private Sub Form_Load()    Dim prn As Printer    For Each prn In Printers        cmbPrinter.AddItem prn.DeviceName    Next    If cmbPrinter.ListCount = 0 Then        cmdPrint.Enabled = False    Else        cmbPrinter.ListIndex = 0    End IfEnd Sub Private Sub cmdPrint_Click()    On Error GoTo exit_sub        Dim prn As Printer    For Each prn In Printers        If prn.DeviceName = cmbPrinter.Text Then            'If ckL.value = True Then prn.Orientation = cdlLandscape            'If ckP.value = True Then prn.Orientation = cdlPortrait            'prn.Copies = Val(txtCopies.Text)            txtPreview.SelPrint prn.hDC            Exit For        End If    Next        Exit Sub    exit_sub:    MsgBox Err.Description, vbExclamation, Err.Source & " (" & Err.number & ")"End Sub


As you can see, I'm filling a combo box with all the available printers, then using the selected on's hDC to print my Rich Text Box (txtPreview)

Now the code above works fine, but as you can see theres 3 lines commented out. If I un comment them, I get the Error "Copies/Orientation property is read-only", how can I set my program up to print the text box without having to use the Common Control?

I know it's possible, but how do you set the orientation, and/or number of copies if they're read only??!

Thanks for reading

--Vit

Resolved When Printing Access Data Form
ok i run a query and it puts every thing in an order
what i want to do is number it
from 1 to what ever the record is
as it is printing the form
or have i got to do it some other way
like
line = 1
let line = line + 1
if you see what i mean
cheers
Doug


vb6 and access 2003
also newbie
may the force be with you

Edited by - dougvcd on 7/8/2005 6:08:48 PM

Copyright © 2005-08 www.BigResource.com, All rights reserved