Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force printer orientation for printing HTML pages 1

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
GB
I need to change the printer orientation before printing an HTML page and then set it back to the previous orientation. It seems that changing the orientation in VB doesn't affect the orientation when it opens the print dialog box using the method I'm using - which may be wrong.

Any alternatives, or ways to force the orientation?

Code:
  Printer.Orientation = vbPRORLandscape
  Shell "rundll32.exe MSHTML.DLL,PrintHTML " & Chr$(34) & "D:\temp\test.htm" & Chr$(34)

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
You may have to go the API way. Look at OpenPrinter followed by a call to SetPrinter...



Good Luck

 
I looked into SetPrinter and related things, SetPrinter seems to have more to do with the print queue than the printer (from the limited number of examples I could find).

I could use the WebBrowser control to do the print - is there a ExecWB parameter for setting the orientation - I can't find one but then neither can I find a complete list of OLECMD commands either.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Just a little search (click this, click that, click the other) will find this...

typedef enum
{
OLECMDID_OPEN = 1,
OLECMDID_NEW = 2,
OLECMDID_SAVE = 3,
OLECMDID_SAVEAS = 4,
OLECMDID_SAVECOPYAS = 5,
OLECMDID_PRINT = 6,
OLECMDID_PRINTPREVIEW = 7,
OLECMDID_PAGESETUP = 8,
OLECMDID_SPELL = 9,
OLECMDID_PROPERTIES = 10,
OLECMDID_CUT = 11,
OLECMDID_COPY = 12,
OLECMDID_PASTE = 13,
OLECMDID_PASTESPECIAL = 14,
OLECMDID_UNDO = 15,
OLECMDID_REDO = 16,
OLECMDID_SELECTALL = 17,
OLECMDID_CLEARSELECTION = 18,
OLECMDID_ZOOM = 19,
OLECMDID_GETZOOMRANGE = 20
OLECMDID_UPDATECOMMANDS = 21
OLECMDID_REFRESH = 22
OLECMDID_STOP = 23
OLECMDID_HIDETOOLBARS = 24
OLECMDID_SETPROGRESSMAX = 25
OLECMDID_SETPROGRESSPOS = 26
OLECMDID_SETPROGRESSTEXT = 27
OLECMDID_SETTITLE = 28
OLECMDID_SETDOWNLOADSTATE = 29
OLECMDID_STOPDOWNLOAD = 30
OLECMDID_ONTOOLBARACTIVATED = 31,
OLECMDID_FIND = 32,
OLECMDID_DELETE = 33,
OLECMDID_HTTPEQUIV = 34,
OLECMDID_HTTPEQUIV_DONE = 35,
OLECMDID_ENABLE_INTERACTION = 36,
OLECMDID_ONUNLOAD = 37
} OLECMDID;

Specifies which command to execute. (The commands in this enumeration are the standard commands defined by Microsoft® Office 95.) A single value from this enumeration is passed in the nCmdID parameter of the IOleCommandTarget::Exec method.

OLECMDID_OPEN
File menu, Open command.
OLECMDID_NEW
File menu, New command.
OLECMDID_SAVE
File menu, Save command.
OLECMDID_SAVEAS
File menu, Save As command.
OLECMDID_SAVECOPYAS
File menu, Save Copy As command.
OLECMDID_PRINT
File menu, Print command.
OLECMDID_PRINTPREVIEW
File menu, Print Preview command.
OLECMDID_PAGESETUP
File menu, Page Setup command.
OLECMDID_SPELL
Tools menu, Spelling command.
OLECMDID_PROPERTIES
File menu, Properties command.
OLECMDID_CUT
Edit menu, Cut command.
OLECMDID_COPY
Edit menu, Copy command.
OLECMDID_PASTE
Edit menu, Paste command.
OLECMDID_PASTESPECIAL
Edit menu, Paste Special command.
OLECMDID_UNDO
Edit menu, Undo command.
OLECMDID_REDO
Edit menu, Redo command.
OLECMDID_SELECTALL
Edit menu, Select All command.
OLECMDID_CLEARSELECTION
Edit menu, Clear command.
OLECMDID_ZOOM
View menu, Zoom command (see below for details).
OLECMDID_GETZOOMRANGE
Retrieves zoom range applicable to View Zoom (see below for details).
OLECMDID_UPDATECOMMANDS
Informs the receiver, usually a frame, of state changes. The receiver can then query the status of the commands whenever convenient.
OLECMDID_REFRESH
Asks the receiver to refresh its display. Implemented by the document/object.
OLECMDID_STOP
Stops all current processing. Implemented by the document/object.
OLECMDID_HIDETOOLBARS
View menu, Toolbars command. Implemented by the document/object to hide its toolbars.
OLECMDID_SETPROGRESSMAX
Sets the maximum value of a progress indicator if one is owned by the receiving object, usually a frame. The minimum value is always zero.
OLECMDID_SETPROGRESSPOS
Sets the current value of a progress indicator if one is owned by the receiving object, usually a frame.
OLECMDID_SETPROGRESSTEXT
Sets the text contained in a progress indicator if one is owned by the receiving object, usually a frame. If the receiver currently has no progress indicator, this text should be displayed in the status bar (if one exists) as with theIOleInPlaceFrame::SetStatusText method.
OLECMDID_SETTITLE
Sets the title bar text of the receiving object, usually a frame.
OLECMDID_SETDOWNLOADSTATE
Sent by the object when its download state changes. Takes a VT_BOOL parameter, which is TRUE if the object is downloading data or FALSE if it is not.
OLECMDID_STOPDOWNLOAD
Stops the download when executed. Typically, this command is propagated to all contained objects. When queried, sets MSOCMDF_ENABLED. Implemented by the document/object.
OLECMDID_ONTOOLBARACTIVATED
Notifies the object that one of the container's toolbars has received the focus. The object should UI-deactivate any child objects, hide any selection, and set an internal flag. The object should reset this flag when the object gets notified that it or one of its child objects or toolbars has received the focus. While this flag is set, the object should call the container's IOleCommandTarget::QueryStatus method to determine the state of edit items (cut, copy, and paste) and call the container's IOleCommandTarget::Exec method to forward any edit commands to the container. If the object has edit items in its toolbars or menus, they should also be enabled or disabled according to the container's IOleCommandTarget::QueryStatus results. The container's IOleCommandTarget interface can be retrieved by calling the container'sQueryInterface method, requesting IID_IOleCommandTarget.
OLECMDID_FIND
Not currently implemented.
OLECMDID_DELETE
TBD.
OLECMDID_HTTPEQUIV
Sent from the Active Document to the container when the parser finds a META HTTP-EQUIV tag in the document. Takes a VT_BSTR parameter that contains the parameter to the META tag, which is equivalent to an HTTP header. The Active Document can send this command more than once, but must send OLECMDID_HTTPEQUIV_DONE after all the META HTTP-EQUIV tags are processed.
OLECMDID_HTTPEQUIV_DONE
Sent from the Active Document to the container when there are no other META HTTP-EQUIV tags in the document. The Active Document must send this command after sending one or more OLECMDID_HTTPEQUIV commands.
OLECMDID_ENABLE_INTERACTION
Sent by the container to tell the object to either pause or resume any multimedia (audio or animation) in the document. Takes a VT_BOOL parameter, which is TRUE if the multimedia should be resumed or FALSE if it should be paused. The Internet Explorer 4.0 browser uses this command to inform the object of when it is minimized or completely covered by another window so that the object can pause playing of multimedia information.
OLECMDID_ONUNLOAD
Sent by the browser before a new navigation is initiated or the browser is being closed. This provides the opportunity for a document to query the user if any unsaved data should be saved. Returning S_OK allows the navigation to close. Returning S_FALSE prevents the operation. This command is sent only once. Because navigation is asynchronous, it is important to remember that the user can make changes in a page or document after this command is received but before the new page is displayed.
In OLE compound documents technology, an object that is being edited in-place disables the Zoom control on its toolbar and the Zoom command on its View menu, because the Zoom command applies logically to the container document, not to the object. The OLECMDID_ZOOM and OLECMDID_GETZOOMRANGE commands notify the container's frame object of the zoom range it should use to display an Active Document in its user interface. The container frame is the client-side object that implementsIOleInPlaceFrame and, optionally, IOleCommandTarget.

The OLECMDID_ZOOM command takes one LONG argument as input and writes one LONG argument on output. This command is used for three purposes:

To query the current zoom value. The caller of IOleCommandTarget::Exec passes OLECMDEXECOPT_DONTPROMPTUSER as the execute option in the nCmdExecOpt parameter and NULL for pvaIn. The object returns the current zoom value in pvaOut. When the object goes UI active, it retrieves the current zoom value from the container's frame object using this same mechanism and updates its zoom control with the returned value.
To display the Zoom dialog box. The caller of IOleCommandTarget::Exec passes OLECMDEXECOPT_PROMPTUSER in nCmdExecOpt. The caller can optionally pass the initial value for the dialog box through pvaIn; otherwise pvaIn must be NULL. If the user clicks Cancel, the object returns OLECMDERR_E_CANCELED. If the user clicks OK, the object passes the user-selected value in pvaOut. When the user chooses the Zoom command from the View menu, the object calls the container's frame object in the same manner. The container then zooms the document to the user-selected value, and the object updates its Zoom control with that value.
To set a Zoom value. The caller of IOleCommandTarget::Exec passes OLECMDEXECOPT_DONTPROMPTUSER in nCmdExecOpt and passes the zoom value to apply through pvaIn. The object validates and normalizes the new value and returns the validated value in pvaOut. When the user selects a new zoom value (using the Zoom control on the toolbar, for instance), the object calls the container's frame object in this manner. The container zooms the document to 100 percent, and the object updates the Zoom control with that value.
The OLECMDID_GETZOOMRANGE command is used to determine the range of valid zoom values from an object that implements IOleCommandTarget. The caller passes MSOCMDEXECOPT_DONTPROMPTUSER in nCmdExecOpt and NULL for pvaIn. The object returns its zoom range as a DWORD in pvaOut, where the HIWORD contains the maximum zoom value and the LOWORD contains the minimum zoom value. Typically this command is used when the user drops down the Zoom control on the toolbar of the UI-active object. The applications and objects that support this command are required to support all the integral zoom values that are within the (min,max) pair they return.

Okay, how I got there. In the MSDN help files, on the index tab, type in execwb. There should be ExecWB and ExecWB Method. Select the first one (ExecWB). Click the link IWebBrowser2::ExecWB (See IWebBrowser2::ExecWB in the Platform SDK.) Click on OLECMDID. When the dialog pops up, there should be two choices, pick one as both go to the same information...

Definitly not the easiest information to get to... :)




Good Luck

 
Thanks - no it isn't easy to find, not least because doing a search for "OLECMD" doesn't find that page at all but "OLECMDID" does! Anyway, sadly it still doesn't help with the original problem.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Thanks, I tried it out and although it looks promising I can't get it to work with a WebBrowser object because a WB doesn't have a .Print method. I've tried using ExecWB to print (which works) except it doesn't then use the printer object we created using PageSet.

Still, good find - deserves a star for perseverence!

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
The DHTMLEdit control does though. I tend to prefer it over a WebBrowser control because it can also be in Edit Mode and used as a sort of HTML version of a RichTextBox.

PrintDocument Method

Prints the current document.

Syntax

object.PrintDocument [bfWithUI]

Parameters

object

The DHTML Editing control

bfWithUI

Optional. VARIANT value of type VT_BOOL that specifies whether the method displays the Windows Print dialog box. If the value is set to True, the dialog box is displayed. If the value is set to False, or if the parameter is omitted, the current document is printed silently.

Whether it will inherit settings to the printer made in the VB6 host I haven't tested though. I suppose I should.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top