Results 1 to 2 of 2

Thread: VBA, Adjust brightness and contrast
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Aug 2009
    Location
    Allen, TX
    Posts
    74
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA, Adjust brightness and contrast

    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 #hdl 
            Print #hdl , ""
            Print #hdl , "
    " Print #hdl , "******" Print #hdl , "Scroll = ""YES""" Print #hdl , "LEFTMARGIN=0" Print #hdl , "TOPMARGIN=0" Print #hdl , "" Print #hdl , " " height=" & m_Height1 & _ " border="0">" Print #hdl , "
    " Print #hdl , "" Close hdl End Function
    Last edited by SerenityNetworks; Oct 3rd, 2018 at 01:15 PM.

  2. #2
    Board Regular
    Join Date
    Aug 2009
    Location
    Allen, TX
    Posts
    74
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA, Adjust brightness and contrast

    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.

    PHP 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 Longm_Width1 As Longm_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 by SerenityNetworks; Oct 3rd, 2018 at 02:17 PM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •