Results 1 to 8 of 8

Thread: Print this file!!! its an HTML

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    234

    Print this file!!! its an HTML

    how do i configer a button to Print the file located at a desired location???

    command1 buttone, Print c:\somehtml.html

    Private Sub Command1_Click()
    ??????
    End Sub

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Print this file!!! its an HTML

    try this, but this will print as text file...ie.with html tags...if you want to convert html tags for font formats then you have to write code for that...
    VB Code:
    1. Dim OneLine As String
    2.     Dim FileNum As Integer
    3.  
    4.     Open "C:\somefile.txt" For Input As #FileNum
    5.     Do While Not EOF(FileNum)
    6.         Line Input #FileNum, OneLine
    7.         Printer.Print OneLine
    8.     Loop
    9.     Printer.EndDoc
    10.     Close #FileNum
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: Print this file!!! its an HTML

    If you want to print the formatted html, instead of the html code, you could use the ShellExecute API, with "print" as the operation parameter.

    VB Code:
    1. 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
    2. Private Const SW_HIDE = 0
    3.  
    4. Private Sub Command1_Click()
    5. Dim lngResult As Long
    6.     lngResult = ShellExecute(Me.hwnd, "print", "c:\somehtml.html", vbNullString, vbNullString, SW_HIDE)
    7. End Sub
    Frans

  4. #4
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: Print this file!!! its an HTML

    Quote Originally Posted by Frans C
    If you want to print the formatted html, instead of the html code, you could use the ShellExecute API, with "print" as the operation parameter.

    VB Code:
    1. 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
    2. Private Const SW_HIDE = 0
    3.  
    4. Private Sub Command1_Click()
    5. Dim lngResult As Long
    6.     lngResult = ShellExecute(Me.hwnd, "print", "c:\somehtml.html", vbNullString, vbNullString, SW_HIDE)
    7. End Sub
    I tried that and nothing hapens
    ShellExecute returns 42, I looked up for ShellExecute errors, and none of the errors in the MSDN have value 42....

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Print this file!!! its an HTML

    Open the file in a WebBrowser control and use the ExecWB method to print.

  6. #6
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: Print this file!!! its an HTML

    Quote Originally Posted by penagate
    Open the file in a WebBrowser control and use the ExecWB method to print.
    That's exactly what I did (but did not check new messages until now)

    Thanks

  7. #7

  8. #8
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,794

    Re: Print this file!!! its an HTML

    Quote Originally Posted by cssriraman
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Amm... I resurected a month old thread that is not even mine, I can't mark it as resolved...

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