Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / March 2005



Tip: Looking for answers? Try searching our database.

HTML Printing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan Holmes - 11 Mar 2005 20:03 GMT
If i have an HTML string with valid html and i want it printed like a
browser would how would i do that?  I already use the IE browser
control, save the HTML to a file and load it and print.  I want
something that doesn't require a visible form.  just
thing.RenderAndPrint(html, ....)

dan
Ken Halter - 11 Mar 2005 20:25 GMT
> If i have an HTML string with valid html and i want it printed like a
> browser would how would i do that?  I already use the IE browser control,
> save the HTML to a file and load it and print.  I want something that
> doesn't require a visible form.  just thing.RenderAndPrint(html, ....)
>
> dan

Ok... you lost me with that last line.... is this a .Net question by any
chance?

If so, you'll want to post that question in a .Net group. They all contain
"dotnet" or "vsnet" in their names.
This and all other groups on the MS server that start with
"microsoft.public.vb" are for VB Classic (VB versions 1-6) and were in
existance long before any .Net products were released. While some of the
code looks the same, they are very different products and require a
different set of groups.

Try one of these:
news://microsoft.public.dotnet.general
news://microsoft.public.dotnet.languages.vb

Signature

Ken Halter - MS-MVP-VB - http://www.vbsight.com
Sign up now to help keep VB support alive - http://classicvb.org/petition
Please keep all discussions in the groups..

Dan Holmes - 11 Mar 2005 20:40 GMT
>>If i have an HTML string with valid html and i want it printed like a
>>browser would how would i do that?  I already use the IE browser control,
[quoted text clipped - 5 lines]
> Ok... you lost me with that last line.... is this a .Net question by any
> chance?
Nope. vb6

This code is in an ActiveX dll.  The process doesn't have an UI but this
dll requires a form and the control just to print the HTML.

dan
Ken Halter - 11 Mar 2005 22:17 GMT
> This code is in an ActiveX dll.  The process doesn't have an UI but this
> dll requires a form and the control just to print the HTML.
>
> dan

You might try something like this.... works fine here. The "guts" are behind
Command1... sample needs a textbox and a command button..
'===========
Option Explicit

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

Private Sub Form_Load()
  'Place the full path to your file here....
  Text1.Text = "C:\Temp\Test.htm"
End Sub

Private Sub Command1_Click()
  Const SW_SHOWDEFAULT As Long = 10
  Dim sFullPathToFile As String

  sFullPathToFile = Text1.Text

  Call ShellExecute(0, "Print", sFullPathToFile _
  , 0&, 0&, SW_SHOWDEFAULT)
End Sub
'===========

Signature

Ken Halter - MS-MVP-VB - http://www.vbsight.com
Sign up now to help keep VB support alive - http://classicvb.org/petition
Please keep all discussions in the groups..

Dan Holmes - 15 Mar 2005 04:27 GMT
>>This code is in an ActiveX dll.  The process doesn't have an UI but this
>>dll requires a form and the control just to print the HTML.
[quoted text clipped - 5 lines]
> '===========
> Option Explicit
...

> Private Sub Command1_Click()
>    Const SW_SHOWDEFAULT As Long = 10
[quoted text clipped - 6 lines]
> End Sub
> '===========

is there any way to do this without the print dialog?  I need it to go
directly to the printer without user interaction.

dan
Phil - 16 Mar 2005 22:06 GMT
Hi there,

I ran thru the same problem, asked the question in this very same
newsgroup earlier and it seems that there is no way to bypass the
printer dialog...

At some point in time I was thinking of using Sendkeys to click this
bloody OK button, but couldn't make it to work!

Weird....We are so many out there willing to achieve this...

Phil

> is there any way to do this without the print dialog?  I need it to go
> directly to the printer without user interaction.
>
> dan
Bob O`Bob - 16 Mar 2005 23:28 GMT
> Hi there,
>
[quoted text clipped - 13 lines]
>>
>> dan

There are ways to interact with the dialog other than SendKeys.
For example, here's some snippets of code using a method which
I consider hideously ugly ... but it works.  I'm pretty sure
this is for Outlook Express:

   PostMessage(lExpressWnd, WM_COMMAND, 40116, 0) 'open print dialog
   lPrnDlg = FindWindow("#32770", "Print")
   FindWindowEx(lPrnDlg, 0, "Button", "&Print")   'Find button on dialog
   SendMessage(lOkWnd, BM_CLICKED, 0&, 0&)        'click button

There's other code interspersed with these, but it may help you get the concept.

    Bob
Steven Moschidis - 17 Mar 2005 10:54 GMT
I am sure there is a cleaner way of doing this as MS does it on their
MCP website... if you want to print your qualifications it goes straight
to the printer without displaying a dialog.
I bet this is also one of the undocumented features that we are not
deemed worthy of knowing.

Steven

>> Hi there,
>>
[quoted text clipped - 28 lines]
>
>     Bob
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.