Results 1 to 2 of 2

Thread: Adding Scroll bar to image box in vba

  1. #1
    Member
    Join Date
    Nov 2011
    Posts
    41
    Rep Power
    0

    Adding Scroll bar to image box in vba

    hi everyone,


    after spending around a whole day i couldn't able to find any thing that how to add scroll bar to image box in vba.
    please help me to find this .


    thanks in advance.

    prince

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi Prince,

    The best I could come up with is setup a Combobox with some dimensions.

    In the userform module

    Code:
    Const frmWidth  As Single = 700
    Const frmHeight As Single = 560
    Private Sub ComboBox1_Change()
        
        Dim strSize     As String
        Dim x
        
        If Len(Me.ComboBox1.Value) Then
            strSize = Me.ComboBox1.Value
            x = Split(strSize, "x")
            With Me
                .Height = Application.Max(frmHeight, CLng(x(0)))
                .Width = Application.Max(frmWidth, CLng(x(1)))
            End With
            With Me.Image1
                .Top = .Top
                .Left = .Left
                .Width = CLng(x(1))
                .Height = CLng(x(0))
            End With
        End If
        
    End Sub
    
    Private Sub UserForm_Initialize()
    
        Dim varSize
        
        
        varSize = Array("16x16", "32x32", "64x64", "160x120", "180x132", "256x192", "320x240", "320x400", _
                        "352x288", "400x300", "480x320", "512x342", "544x372", "640x480", "720x540", "800x600", _
                        "1024x768", "1280x1024")
        
        With Me.Image1
            .Picture = LoadPicture("C:\Pictures\DSC02264.jpg")
            .Height = 16
            .Width = 16
        End With
        
        With Me.ComboBox1
            .List = varSize
            .ListIndex = 0
        End With
    
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. Replies: 2
    Last Post: 06-08-2013, 09:32 PM
  2. Vlookup Multiple Values By Adding Formula With Loop In VBA
    By Safal Shrestha in forum Excel Help
    Replies: 15
    Last Post: 04-22-2013, 04:49 PM
  3. Load PNG File in Userform Image Control
    By Tony in forum Excel Help
    Replies: 2
    Last Post: 02-14-2013, 01:21 PM
  4. Scroll Lock and Unlock using VBA
    By LalitPandey87 in forum Excel Help
    Replies: 2
    Last Post: 11-08-2011, 08:59 AM
  5. Adding A Menu Bar To A User Form
    By Rasm in forum Excel Help
    Replies: 14
    Last Post: 05-05-2011, 04:05 AM

Posting Permissions

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