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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print XML with XSL from VB 1

Status
Not open for further replies.

wassup

Technical User
Oct 3, 2000
52
GB
How do you print an XML document run with xsl via VB?
 
Get the msxml 3.0 parser from msdn.microsoft.com

Set a reference to it in your project and use code like this:

Code:
dim oXMLData as MSXML2.DomDocument
dim oXMLStyleSheet as MSXML2.DomDocument
dim sResult as String

Set oXMLData = New MSXML2.DomDocument
Set oXMLStyleSheet = New MSXML2.DomDocument

oXMLData.Load "location_of_xml_file.xml"
oXMLStyleSheet.Load "location_of_xsl_file.xsl"

'Could be TransformNode I'm not sure because I'm
'typing this by heart...
sResult = oXMLData.Transform oXMLStyleSheet

The result string you can put in a file, or display in a browser or whatever you want.

Good luck!

Jordi Reineman
 
That's okay as far as it goes.

Probably a simpler approach (which also actually prints the thing) would be to use the 'WebBrowser' ActiveX control. This can be found on the 'Components' dialog box under 'Microsoft Internet Controls'.

To load the XML document, do:
[tt]WebBrowser1.Navigate &quot;<URL of XML document>&quot;[/tt]

Then, on the WebBrowser1_DocumentComplete event, do:
[tt]WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER[/tt]

If the WebBrowser control is made invisible, the user need not even see the document being printed.

Alternatively, the dll upon which this control is based could be used instead (shdocvw.dll) with the same mechanism.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top