Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Apr 2001
    Location
    Washington
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Printing a Character string with VBA

    I have an Excel form in which I use VBA to do some validating of the data within the form. The validation results are collected in a string that I then display in a message box at the end of the validation. I would like to give the user the option of printing the message by simply sending the string to a printer.

    I have been unable to figure out how to this. I can see how to "Print" and "Write" to files and to the Immediate Window, but how do I send a simple character string to a printer?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing a Character string with VBA

    Dale,

    Just off the top of my head:

    You could either open a new workbook or switch to a blank sheet, enter the string into the first cell then print the sheet/book.

    You could also write a little ditty like this:

    Open "VString.txt" For Output As #1
    Print #1, "Your validation string."
    close #1

    Then print that file:

    shell "command.com /c copy vstring.txt lpt1:"

    OR (might work):
    Open LPT1 for output as #1
    Print #1 "Your validation string."
    close #1

    If you are printing to a network printer substitute the UNC name of the printer for LPT1.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    New Lounger
    Join Date
    Apr 2001
    Location
    Washington
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Printing a Character string with VBA

    Thanks.

    I think the second or thirs option will be the best for me. However, I failed to mention that I need the string to be printed on the default printer of the workstation since this will be used by many users at multiple workstations with multiple network printers defined. Any thoughts on how to do that piece?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •