How to AutoZoom a WebBrowser Control image to fit any screen resolution

Viewed 90

I am working in a Organizational chart project made using Excel VBA (I am new usin it). Basically, there are some buttons that represents departments and employees, and when you click on them, it sends you to the department sheet (department buttons) or it opens a userform (employee button) with informations about the people, photo included.

I get the picture from Sharepoint link, using WebBrowser, so that no one needs to download it on the computer. All pictures have the same 199 x 199 size. Using the company's standard notebook, the picture fits well, but on others screen, it doesn't. If I zoom the photo a little (Ctrl +) it works. So I tried to auto put the cursor on the webbrowser control object by its coordinate or something, but i didn't get it (too advanced for me by just searching and trying to adapt codes).

Is there a way to AutoZoom the image to fit the WebBrowser no matter the screen resolution? Or other solution?

Thanks!

The userform code that shows the informations gotten from a excel table:

Private Sub UserForm_Initialize()

Dim forma As Shape
Dim ult_linha As Integer
Dim caller As Object
Dim DP As String
Dim title As String
Dim Descricao As String
Dim sh As Worksheet
Dim ash As Worksheet
Dim posicaotroca As Integer
Dim nomechange As String
Dim fotografia As String


Set sh = Sheets("Colaboradores")
Set ash = ActiveSheet
Set caller = ash.Shapes(Application.caller)
title = caller.TextFrame.Characters.Text
dpsh = ash.Name

ult_linha = sh.Cells(14, 1).End(xlDown).Row

For linha = 15 To ult_linha

    titulo = sh.Cells(linha, 1).Value
    departamento = sh.Cells(linha, 4).Value


    For Each forma In ash.Shapes
    
        If forma.AutoShapeType = msoShapeRoundedRectangle And dpsh = departamento And titulo = title Then
        

 fotografia = sh.Cells(linha, 6).Value

WebBrowser1.Navigate fotografia
DadosColab.Nome.Caption = sh.Cells(linha, 2).Value
DadosColab.DP.Caption = sh.Cells(linha, 4).Value
DadosColab.Cargo.Caption = sh.Cells(linha, 5).Value
DadosColab.Filial.Caption = sh.Cells(linha, 3).Value
DadosColab.Email.Caption = sh.Cells(linha, 7).Value
DadosColab.Descricao.Caption = sh.Cells(linha, 8).Value


Exit For
    
End If

Next
 
If titulo = title And dpsh = departamento Then
        
    

Exit For
    
End If
    
Next


End Sub
0 Answers
Related