Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2008, 11:22 AM
Registered User
 
Join Date: Jun 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with browser control in VBA form

Hi Everyone

I have some data in XML format in Excel 2000 that I want to display in a VBA form using a web browser control. I apply an XSL transform to convert the XML into the XHTML format I want, complete with an embedded CSS stylesheet.

However, when the output file is viewed in the form the styles have not been applied and everything adopts the default formatting.

For testing purposes I have my XML in cell A1 of my spreadsheet and my XSL in cell A2. I have a form containing a web browser control called wbTest. When I open the form I initialise the web browser by doing the following:

Code:
Private Sub UserForm_Activate()
    Me.wbTest.Navigate2 "about:blank"
End Sub
When the browser is complete I populate it with the result of the transformation by doing the following:

Code:
Private Sub wbTest_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    Dim xXML As DOMDocument
    Dim xXSL As DOMDocument
    Dim sXML As String, sXSL As String, sOutputString As String

    Set xXML = New DOMDocument
    Set xXSL = New DOMDocument
    sXML = Worksheets("Sheet1").Range("A1").Value
    sXSL = Worksheets("Sheet1").Range("A2").Value

    If xXML.loadXML(sXML) And xXSL.loadXML(sXSL) Then
        MyString = xXML.transformNode(xXSL)
        Me.wbTest.Document.body.innerHTML = sOutputString 
    End If
End Sub
I know the resulting XHTML is fine because when I capture the value of sOutputString and open it in a normal browser it looks fine. And when I change the XSL so it doesn't use CSS but adds a style attribute to each tag it looks fine also.

Any idea what I'm doing wrong?

Thanks

sw239

 
Old July 3rd, 2008, 11:06 AM
Registered User
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I found your post while looking for an answer to the same problem today. I don't know whether you're still needing assistance.

I found the solution here:http://www.vbforums.com/showthread.php?t=384076

Instead of:

    Me.wbTest.Document.body.innerHTML = sOutputString

Try:

    With Me.wbTest
        .Navigate "about:blank"
        Do While .ReadyState <> READYSTATE_COMPLETE ' loaded (=4)
            DoEvents
        Loop
        .Document.Write sOutputString
        Do While .ReadyState <> READYSTATE_COMPLETE ' loaded
            DoEvents
        Loop
    End With

I'm guessing "MyString" should be "sOutputString" as you didn't declare it anywhere.


hth,

d





Similar Threads
Thread Thread Starter Forum Replies Last Post
Browser Control In C# [email protected] C# 2005 2 January 8th, 2008 07:12 AM
Browser Control using C# 2.0 [email protected] C# 2005 0 November 15th, 2007 12:04 AM
Problem with Web Browser control in vc++ sureshkumarct Visual C++ 0 May 29th, 2006 04:01 AM
Problem with Calendar Control in VBA narendrapawar VB How-To 0 December 16th, 2004 09:08 AM
web form control problem myavi ADO.NET 1 June 5th, 2004 12:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.