CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2000
    Posts
    264

    Writing and Printing from a File

    I would like to generate a HTML file based on data I retrieve from the database. I want to be able to write the file, save the file, and print the file automatically with no user intervention. Can anyone give me a clue as to how to write the HTML file and then automatically print it?

    Many thanks for any suggestions!
    Greg


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Writing and Printing from a File


    Open "c:\temp\temp.html" For Output As #1 'to write to
    Print #1, YourString
    Close #1


    'to print

    Private Declare Function ShellExecute 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

    Dim lngResult As Long
    lngResult = ShellExecute(Me.hwnd,"Print",strFile,0&,0&,vbMinimized)

    where strFile is the full path to your file





    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Jan 2000
    Posts
    264

    Re: Writing and Printing from a File

    Ok, thats fine but it brings up the printer box and requires the user to select a printer and to click the OK button. I need a way to print the file without the user to click OK.

    Thanks,
    Greg


  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Writing and Printing from a File

    Open "c:\temp\temp.html" For Input As #1 'to read from
    Do While Not EOF(1)
    Line Input #1, sLine
    Printer.Print sLine
    Loop
    Close #1


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  5. #5
    Join Date
    Jan 2000
    Posts
    264

    Re: Writing and Printing from a File

    Won't this print the actual HTML text and not the processed HTML??


  6. #6
    Join Date
    Jul 2001
    Posts
    3

    Re: Writing and Printing from a File


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured