Consulting

Results 1 to 4 of 4

Thread: Insert Photo in Cell, using Userform

  1. #1

    Insert Photo in Cell, using Userform

    Dear User,

    I have a query while doing this thing. I have a userform which have three things.

    (1) Image1
    (2) Attach Photos Button (cmdattach)
    (3) Submit Photos Button (cmdsubpic)

    When i click on Attach Photos Button its get a Dialog Box of Choose Image File, if i choose image it get displayed in Image1.

    Now the problem which i am facing is :

    When i click on Submit Photos Button the image is not going to particular place.. I mean to say image is not appearing on Worksheet. Its showing some alphanumeric things.

    Please test the file before writing u r code. To know what i want exactly

    Warm Regards,
    Harindra Devadiga

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Fairly cheesy, but maybe enough to get you started. I would note that if you are going to use the image control to preview the pic, then you are limited to the formats taht the control supports. For instance, (in 2000 leastwise) you wouldn't be able to insert a .png pic.

    Anyways, try:

    [vba]Dim fname As String

    Private Sub cmdattach_Click()


    fname = Application.GetOpenFilename(filefilter:= _
    "Picture Files(*.bmp; *.cur; *.gif; *.ico; *.jpg; *.wmf)," & _
    "*.bmp; *.cur; *.gif; *.ico; *.jpg; *.wmf", Title:="Select Image To Open")

    If fname <> "False" Then
    Image1.Picture = LoadPicture(fname)
    Me.Repaint
    End If

    End Sub


    Private Sub cmdsubpic_Click()
    Dim iRow As String
    Dim ws As Worksheet

    Set ws = Worksheets("Sheet1")

    iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    ws.Cells(iRow, 1).Select

    If Not fname = "False" _
    And Not fname = vbNullString Then

    ActiveSheet.Pictures.Insert (fname)
    ws.Cells(iRow, 1).Select
    End If
    End Sub[/vba]

    Hope this helps,

    Mark

  3. #3
    Thanks GTO, but the thing which i want is to every fresh entry i want a next row

    Like if i have 3 Images & i want to insert it

    Row 1 Image 1
    Row 2 Image 2
    Row 3 Image 3

    Hope you get me...

    Warm Regards,
    Harindra G. Devadiga

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    Something like this you mean...
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

Posting Permissions

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