PDA

View Full Version : help me please



shahabsoltan
07-19-2014, 07:35 AM
hi
I do not know what's wrong with my code

patel
07-19-2014, 08:02 AM
I don't understand your goal, but your code works well, check path and filename

see http://www.vbaexpress.com/forum/faq.php?faq=new_faq_item#faq_posthelp_faq_item about the title

shahabsoltan
07-19-2014, 10:35 AM
my friend
thanks for the answer
but the path and filename arr correct
please leve the sample
thank you

patel
07-19-2014, 11:07 AM
I tested your file, I changed path according to my drive, it works

shahabsoltan
07-19-2014, 11:38 AM
Where are you from my friend

shahabsoltan
07-19-2014, 11:48 AM
This error message indicates
"file not found"
However, the existing file is

patel
07-19-2014, 09:19 PM
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")

HaHoBe
07-19-2014, 11:43 PM
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

shahabsoltan
07-20-2014, 05:10 AM
hi my friends
thank you for answer
but do not be
please leve the sample

HaHoBe
07-20-2014, 05:40 AM
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

shahabsoltan
07-20-2014, 07:26 AM
sorry, hahobe
please translate use (Persian to English)
هرکاری میکنم نمیشود

HaHoBe
07-20-2014, 08:06 AM
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

shahabsoltan
07-20-2014, 08:11 AM
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

shahabsoltan
07-20-2014, 08:20 AM
happy germa soccer championship:hi:

shahabsoltan
07-20-2014, 08:23 AM
happy german soccer championship :hi:

HaHoBe
07-22-2014, 07:30 AM
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