+ Reply to Thread
Results 1 to 4 of 4

resizing image in userform

  1. #1
    Registered User
    Join Date
    11-15-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    resizing image in userform

    Hi, I'm working a code which gets an image from my folder and shows it on the userform. However, I would like to increase the size of the image so it can be seen better.

    Below is the code to get the image. However, I am not sure how to increase the size as my VBA knowledge is very limited. Any help would be appreciated.

    Private Sub btnShowDrugImage_Click()
    Dim fPath As String
    Dim fName As String
    Dim RowCount As Range
    Dim RowCell As Integer
    Dim ColumnCell As Integer


    fPath = "C:\drugimages\"
    fName = ""

    Set RowCount = Worksheets("Sheet2").Range("A1:A100000").Find(cboDrugImageMedication.Value, lookat:=xlPart)
    If Not RowCount Is Nothing Then
    RowCell = RowCount.Row
    ColumnCell = RowCount.Column
    fName = Worksheets("Sheet2").Cells(RowCell, ColumnCell + 1).Value
    fPath = fPath & fName & ".jpg"
    imgDrugImage.Picture = LoadPicture(fPath)
    MsgBox "Here is your image"
    imgDrugImage.Picture = LoadPicture("")
    End If
    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: resizing image in userform

    There is a PictureSizeMode property for the image control to set it to zoom to fit (fmPictureSizeModeZoom). The image will then be automatically zoomed to fit within the Image control. You can set this property in the VBA properties window or by using the line of code below.

    imgDrugImage.PictureSizeMode = fmPictureSizeModeZoom

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: resizing image in userform

    I do not think C# will be helpful with Excel VBA.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: resizing image in userform

    Also this thread is > 1 year old.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1