Consulting

Results 1 to 16 of 16

Thread: help me please

  1. #1

    help me please

    hi
    I do not know what's wrong with my code
    Attached Files Attached Files

  2. #2
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    I don't understand your goal, but your code works well, check path and filename

    see http://www.vbaexpress.com/forum/faq....thelp_faq_item about the title
    Last edited by patel; 07-19-2014 at 08:34 AM.

  3. #3
    my friend
    thanks for the answer
    but the path and filename arr correct
    please leve the sample
    thank you

  4. #4
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    I tested your file, I changed path according to my drive, it works

  5. #5
    Where are you from my friend

  6. #6
    This error message indicates
    "file not found"
    However, the existing file is

  7. #7
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    try removing space after pic, with this line
     Label1.Picture = LoadPicture("C:\Users\Fcc\Desktop\pic" & Cells(1, 1) & ".jpg")
    instead of
     Label1.Picture = LoadPicture("C:\Users\Fcc\Desktop\pic " & Cells(1, 1) & ".jpg")

  8. #8
    VBAX Regular HaHoBe's Avatar
    Joined
    Aug 2004
    Location
    Hamburg
    Posts
    89
    Location
    Hi, shahabsoltan,

    I wonder why you use a Worksheet_Event like changing the cells on a worksheet to load a static picture (I would expect you to use either Workbook_Open in ThisWorkbook or Worksheet_Activate behind the sheet instead).

    You should consider to describe what you want by using the code (load a picture sure but will that always just be one picture, always the same, should you care for different pictures, do you want a dialog to choose from).

    Like stated I think you use the wrong event to get the picture loaded but you may avoid the switch to the VBE by using
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Dim strPic As String
    
    Const cstrPATH As String = "C:\Users\Fcc\Desktop\"
    
    strPic = cstrPATH & "pic " & Cells(1, 1) & ".jpg"
    
    If Len(Dir(strPic)) > 0 Then
      Label1.Picture = LoadPicture(strPic)
    Else
      MsgBox "Please check Folder and Name for " & strPic
    End If
    
    End Sub
    This should display the Message Box permanently on each change of cell and ask for a check of Folder and File.

    Ciao,
    Holger

  9. #9
    hi my friends
    thank you for answer
    but do not be
    please leve the sample

  10. #10
    VBAX Regular HaHoBe's Avatar
    Joined
    Aug 2004
    Location
    Hamburg
    Posts
    89
    Location
    Hi, shahabsoltan,

    sorry but what does it mean you posted, esp
    but do not be
    Please be reminded that you will need to tell us what you want to achieve (in simple words).

    Ciao,
    Holger

  11. #11
    sorry, hahobe
    please translate use (Persian to English)
    هرکاری میکنم نمیشود

  12. #12
    VBAX Regular HaHoBe's Avatar
    Joined
    Aug 2004
    Location
    Hamburg
    Posts
    89
    Location
    Hi, shahabsoltan,

    google translation doesnīt make much sense to me either ("Everything I Can not (Be)"). We are looking forward to help you but for doing so we would need information about what you want to do, why you use this event, if you want any other picture inserted into the frame or just the one from this cell, if the name within the cell would change, if any other pictures all would be in the same folder etc.

    Ciao,
    Holger

  13. #13
    I'm using this method for each selected photo
    So I seriously need this formula
    But whatever I try not to be
    I'm hoping to transfer data
    Thank you for your attention

  14. #14
    happy germa soccer championship

  15. #15
    happy german soccer championship

  16. #16
    VBAX Regular HaHoBe's Avatar
    Joined
    Aug 2004
    Location
    Hamburg
    Posts
    89
    Location
    Hi, shahabsoltan,

    I still donīt know what you want and what isnīt working on your system and why.

    Why do you use the Worksheet_SElectionChange event to load the picture? There is only one number available.
    Will there be oine folder with all other pictures as well?
    Where will the other cells for the pictures be located on the sheet?

    CIao,
    Holger

Posting Permissions

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