VBA, Adjust brightness and contrast

SerenityNetworks

Board Regular
I'm using several instances of the Private Function code below to display multiple images within an Excel form. It works fine. but I need to be able to adjust the brightness and contrast of the image displayed in each of the web containers. In the past, I've displayed images directly on a worksheet, then used the following code to change the contrast (and similarly for brightness). But I'm not figuring out how to do it for the images in the web containers. I could really use some help. (Note: I'm a hobbyist, not a coder. My VBA skills are limited.)

Thanks in advance,
Andrew

Code:
Sub SetContrast()
    Dim shape As Excel.shape
    Dim cnt As Long
    cnt = 0
    For Each shape In ActiveSheet.Shapes
        If shape.Type = msoLinkedPicture Then
            shape.PictureFormat.Contrast = gvarGlobalContrast
        End If
    Next shape
End Sub
Code:
Private Function fnCreateHTML1(strImgFilePath As String)
'//-----------------------------------------
'// Author    : "Ivan F Moala"
'// Site      : "http://www.xcelfiles.com"
'-------------------------------------------
Dim hdl As Long, m_Width1 As Long, m_Height1 As Long
Dim strAp1 As String

strAp1 = Chr(34)
m_Width1 = WebBrowser1.Width * HWF1    'WebBrowser1.Width * 1.325 is ratio of 96 / 72
m_Height1 = WebBrowser1.Height * HWF1
hdl = FreeFile

    Open strPath & "Tmp1.html" For Output As [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] 
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , ""
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , "<center>"
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , "******"
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , "Scroll = ""YES"""
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , "LEFTMARGIN=0"
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , "TOPMARGIN=0"
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , ""
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , "[IMG]https://www.mrexcel.com/forum/ & strAp1 & picURL1 & strAp1 & _<br />                     [/IMG]                    " height=" & m_Height1 & _
                    " border="0">"
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , "</center>"
        Print [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=hdl"]#hdl[/URL] , ""
    Close hdl
End Function
 
Last edited:

SerenityNetworks

Board Regular
I just noticed that my pasted code for the web container chopped out code. I'm pasting it again using php tags. It's pasting cleanly now.

Code:
Private Function fnCreateHTML1(strImgFilePath As String)
'// Using this code, the images will be loaded and stretched to fit "full-screen" into the form's browser window.
'//-----------------------------------------
'// Author    : "Ivan F Moala"
'// Site      : "http://www.xcelfiles.com"
'-------------------------------------------
Dim hdl As Long, m_Width1 As Long, m_Height1 As Long
Dim strAp1 As String

strAp1 = Chr(34)
m_Width1 = WebBrowser1.Width * HWF1    'WebBrowser1.Width * 1.325 is ratio of 96 / 72
m_Height1 = WebBrowser1.Height * HWF1
hdl = FreeFile

    Open strPath & "Tmp1.html" For Output As #hdl
        Print #hdl, "<HTML>"
        Print #hdl, "<CENTER>"
        Print #hdl, "******"
        Print #hdl, "Scroll = ""YES"""
        Print #hdl, "LEFTMARGIN=0"
        Print #hdl, "TOPMARGIN=0"
        Print #hdl, "</BODY>"
        Print #hdl, "<IMG width= " & m_Width1 & _
                    " height= " & m_Height1 & _
                    " SRC = " & strAp1 & picURL1 & strAp1 & _
                    "; Border = 0>"
        Print #hdl, "</CENTER>"
        Print #hdl, "</HTML>"
    Close hdl
End Function
 
Last edited:

Some videos you may like

This Week's Hot Topics

Top