Forum Discussion

1 Reply

  • SethGonzalez's avatar
    SethGonzalez
    Iron Contributor

    1. Quick adjustment method
    Right-click the WebBrowser control → Properties
    Modify the key parameters:
    ScrollBars = 0 (no scrollbars)  
    ScrollWidth = 100%  
    ScrollHeight = 100%  
    2. VBA autoscaling code
    Dynamic scaling script:
    vba
    Private Sub Worksheet_Activate()
        With Me.WebBrowser1
            .Object.Document.Body.Style = “zoom:85%; margin:0; padding:0;”
            Object.Document.Body.Scroll = “no”
        End With
    End Sub
    (Macros need to be enabled, press Alt+F11 to insert code)
    3. HTML content optimization
     Force responsive layout:
    Add <meta> tags to the loaded HTML:
    html
    <meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
    Run the HTML
    and control it with CSS:
    css
    img { max-width: 100%; height: auto; }
    4. Alternatives
     Use Power Query to fetch web content:
    Data → Get Data → From Other Sources → From Web
    Right click on the image after importing → choose “Fit to cell”
     Office JS API (online version of Excel):
    javascript
    Office.context.document.setSelectedDataAsync(htmlContent, {coercionType: “html”});