Solved

Automatically printing HTML pages

Posted on 2002-04-26
13
213 Views
Last Modified: 2008-02-01
I have a site which displays application forms in HTML on a private entry web site.

I am trying to build a VB application that will go to the most recently received application on the site and send the HTML content straight to the printer with no user intervention (don't want the print dialog box to appear).

I may also need to set the printer's page orientation to Landscape in order to optimise the printed output.

I am planning to use an embedded Internet Explorer page in the VB form to receive the HTML and then send the rendered output to the printer. the contents will be rendered in an IFrame.

Am I mad doing things this way ? Is there a better or easier way of doing this ?
0
Comment
Question by:milsy
  • 5
  • 3
  • 3
  • +1
13 Comments
 

Accepted Solution

by:
Leandro earned 200 total points
Comment Utility
You can use de WebBrowser (SHOWDOCVW.dll) control's Navigate method to show the html document.

  And then invoke the ExecWb method to print the page:

    Webbrowser.ExecWb OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL

  Where OLECMDID_PRINT = 6 and OLECMDEXECOPT_DONTPROMPTUSER = 2.

  It will print the page without propmting anything to the user.

  To set the printer's orientation you use this code:

  Printer.Orientation = vbPRORLandscape

I hope it helps you, and sorry for my poor english.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
Leandro,

Welcome to EE. Please do not lock questions with answers.  If you are unsure of the policy, re-read the EE Guidelines (http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp)

Anthony
0
 

Expert Comment

by:Leandro
Comment Utility
Anthony,
 I've got your point, but if you don't want that someone lock the question, why to create a system that does that, I think my answer is clear and specifc, and I agree that locking the question is not good, so if we must always put comments, why to keep this "answer" loking system?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
That is a question best directed at Community Support (http://www.experts-exchange.com/commspt/), but I believe your question is one of the most frequently asked questions.

Anthony
0
 

Expert Comment

by:Leandro
Comment Utility
Anhony, is it possible to turn an answer into a comment to unlock the question ?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
The only way I am familiar with is when the questioner rejects an answer.

Anthony
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
hearing...
0
 

Author Comment

by:milsy
Comment Utility
Thanks Leandro. Your English is good enough for me to understand the given answer so don't worry.

I had tried using the Webrowser control before asking the question but I hadn't managed to get the OLECMDEXECOPT_DONTPROMPTUSER option to work.

Thanks again.

Shane
0
 

Expert Comment

by:Leandro
Comment Utility
I'm glad I could help you. Thanks for the poins.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Strange, code provided works fine and you give "B" grade?
0
 

Author Comment

by:milsy
Comment Utility
The point is Richie that I still haven't got the DONTPROMTUSER option to work and as I need this to act as a robotic process then I haven't quite reached the answer I was originally hoping for... hence the the "B" grade... a good answer but not a total solution.

Shane
0
 

Expert Comment

by:Leandro
Comment Utility
Oh, and I forgot to tell you that some things just don't work in Vb, and this is an example: the OLECMDEXECOPT_DONTPROMPTUSER flag does not work, I am sorry, but I have forgotten this.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
That flag depends upon which version of IE you have. In IE4 and 5.0, it works (if i remember well), if you have latter version, IE doesn't cares about it and shows the dialog anyway.
But, if you need more help, don't accept a comment until matter is resolved at your wishes or you found that it is impossible to do.
Anyway, you can avoid it not using IE objects.
Cheers
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now