Results 1 to 13 of 13

Thread: Printing HTML [Resolved]

  1. #1

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Resolved Printing HTML [Resolved]

    Does anyone know of a way to print HTML without using the Internet Explorer Object? I ask as I need a way to print multiple pages (only asking for the settings at the start and using them throughout), and to print without the headers and footers that IE adds by default

    Thanks
    Last edited by Arachnid13; Jan 28th, 2008 at 10:46 AM. Reason: Resolved
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: Printing HTML

    Wouldn't you need to first get the HTML from the site? Or do you already have it? You just want to print out specific parts of it?

  3. #3
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: Printing HTML

    Regards
    Srinivasan Baskaran
    India

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Printing HTML

    But that code bank entry is all based upon the web browser control (IE).

    If you download the html source of the page using Inet control you can write it to a file for printing locally as any regular file you would do.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Re: Printing HTML

    The HTML is stored locally. RobDog, how would you print an html file locally using code without getting the header/footers?
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  6. #6
    Addicted Member
    Join Date
    May 2005
    Posts
    137

    Re: Printing HTML

    I managed to do this using the ie control

    all I did was when I printed, changed the registry so it didn't add all the header and footer infor , then when it had finished printing it put it back to default.

    maybe not the nicest way of doing it but it worked for me

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Printing HTML

    How about something as simple as
    Code:
    Private Function PrintTextFile(sTextFile As String) As String
    If Dir(sTextFile) <> vbNullString Then
        Open sTextFile For Binary As #1
        PrintTextFile = Input(LOF(1), 1)
        Close #1
    End If
    End Function
    
    Private Sub Command1_Click()
    Screen.MousePointer = vbHourglass
    Printer.Print PrintTextFile("c:\MyPage.htm")
    Printer.EndDoc
    Screen.MousePointer = vbDefault
    End Sub

  8. #8
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: Printing HTML

    Code:
    ShellExecute 0&, "Print", "C:\Innovation\Temp\<filename>.html", "", "", vbNormalFocus
    Try the above code...
    Regards
    Srinivasan Baskaran
    India

  9. #9

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Re: Printing HTML

    Not able to test either right now but Hack wont your solution just print the source code? And cheenu_vasan all your way does is print it with internet explorer behind the scenes so it will again rely on the registry values, i think i'm gonna have to use ooKmonkeys method and edit the registry, does anyone know if the values are always in HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup? or are they in different places for earlier versions of ie?
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Printing HTML

    Quote Originally Posted by Arachnid13
    Not able to test either right now but Hack wont your solution just print the source code?
    Yes, but this
    Quote Originally Posted by Arachnid13
    The HTML is stored locally.
    tells me that you have a local file of HTML that you want printed.

  11. #11

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Re: Printing HTML

    My apologies hack, i have the html locally because it's my program thats generating it, and i want to print it as it would look when rendered in a browser, anyway i solved the second part of my problem with the registry editing myself so this thread is now resolved.

    Thanks everyone
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Printing HTML [Resolved]

    Post your resolution as it might benefit someone else with the same or similiar problem.

  13. #13

    Thread Starter
    Hyperactive Member Arachnid13's Avatar
    Join Date
    Jan 2003
    Location
    England
    Posts
    327

    Re: Printing HTML [Resolved]

    No problem,

    I used the module attached by schoolbusdriver in post #7 of this thread:
    http://www.vbforums.com/showthread.php?t=491870

    The UpdateKey and GetKeyValue procedures were exactly what i needed
    Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White

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