hi
I have a jpeg image that the path is saved to a cell, i hyperlink to userform but cannot get it to resize and show in userform image control box,just ap
pears on screen
any ideas please
cheers colin
hi
I have a jpeg image that the path is saved to a cell, i hyperlink to userform but cannot get it to resize and show in userform image control box,just ap
pears on screen
any ideas please
cheers colin
Last edited by cfinch100; 07-28-2013 at 01:37 PM.
Colin
What do you mean you 'hyperlink' to the userform?
If posting code please use code tags, see here.
hi
on sheet in a cell, I open hyper link and load picture wanted ,I put cmdbutton on form and addwhere tb15 is the name of the picture saved ,when commandbutton is clicked it loads picture to full screen,where I can print this is .pdf,i converted this picture to jpeg and did same again but this loads to half screen and not in image box,its there fairly instantly ,added![]()
ThisWorkbook.FollowHyperlink TextBox15.Value
to private sub listbox,works well,in unit type 100,in list box click on any of top 2 entries ,path comes up in tb15 and picture loads but not in box and too big![]()
ThisWorkbook.FollowHyperlink TextBox15.Value
hope this helps
cheers colin
Colin
Why are you hyperlinking?
If you want to load an image in an image control use LoadPicture.
Hyperlinking is just going to open it in a browser window.s
Accidental duplicate.
hi
having problems with using load picture,have tried a few different ones and cannot get it right,can enter picture in properties ,it loads but not resize to fit and this only lets me load one picture
cheers colin
Colin
What problems are you having?
Wrong picture? Wrong size? Exploding monitor?
hi norie
will not load picture all
cheers colin
Colin
Can you post the code you are using to try and load the picture?
Also, are you sure that code is actually executing?
hi norie![]()
Object.Picture = LoadPicture(c\users\colin\desktop\50td213.jpeg)
this is the code in listbox
cheers colin
Sorry, the code is where?
in the private sublistbox click
cheers colin
Works fine for me, have you checked the path and filename are valid?
hi
yes now keeps saying path not found,will keep trying
cheers colin
At least something's happening now.
PS Why not set up a dummy form with an image control in a blank workbook and test things there?
hi norie
will do thanks
cheers colin
hi norie
have done that if I put .jpeg it says path can not be found if I put .jpeg.jpg says object not found,even moved file to c:\5t.jpeg
,cheers colin
hi
I have found code on a forum but when I run says it can not find file ,but its there any ideas please,had it display one jpeg pic when adjusted code in private sub listbox ,but no other, please help required
cheers colin
for the first step you can try to add it on your userform...then you'll see how to control it
![]()
Private Sub UserForm_Initialize() ComboBox1.SetFocus Set MyData = Sheet1.Range("a1").CurrentRegion 'database With Me .Caption = "Database Example" 'userform caption .Height = frmHt .Width = frmWidth End With Image1.Picture = LoadPicture("C:\Documents and Settings\blue\Desktop\office.jpg") End Sub
blue
Colin
Your code doesn't check for the existence of a file.
If you want to do that use Dir.
Where is the actual path anyway, you only seem to have a filename, and that doesn't look right - for one thing files don't normally have 2 file extensions.
What is the actual path to the image(s)?
If you aren't sure of that open Windows Explorer, navigate to the folder then either copy the path from the address bar or right click and select Copy Address as text.
Then you can paste it somewhere.
What are there file names?
If you want to find out the filenames you could run this in an empty workbook.
![]()
Sub ListJPGs() Dim rng As Range Dim strFileName As String Dim strPath As String Set rng = Range("A1") strPath = "C:\Pictures\" ' change this to whatever path you got when you opened Explorer as suggested above strFileName = Dir(strPath & "*.jpg") While strFileName <>"" rng.Value = strFileName Set rng = rng.Offset(1) strFileName = Dir() Wend End Sub
hi blue.chio
have done that and brings first one up no problem , run time error 53 occurs when I change the number eg 1t.jpeg to 5t.jpeg although the path is the same up to that double click on the file on sheet1 opens it up though
cheers colin
try to add a listbox, let' s say listbox2 and just try to see if the images are changing...
and![]()
Private Sub UserForm_Initialize() ' ' ListBox2.AddItem "picture1" ListBox2.AddItem "picture2" End Sub
![]()
Private Sub ListBox2_Click() If ListBox2.Value = "picture1" Then Image1.Picture = LoadPicture("C:\Documents and Settings\blue\Desktop\office1.jpg") ElseIf ListBox2.Value = "picture2" Then Image1.Picture = LoadPicture("C:\Documents and Settings\blue\Desktop\office2.jpg") End If End Sub
Have a look at the attached.
It's a bit rough but perhaps it'll help.
hi
run time 424 with blue chio answer and my path iswhich seems to be right ,loads one pic but no others![]()
c:\users\colin\desktop\1t.jpeg
cheers colin
Last edited by cfinch100; 07-28-2013 at 11:05 AM.
hi norie
have tried that and all files are there and same as on sheet have tested from sheet they all ok,just goes amiss when try to put on userform ,more than one picture anyhow
cheers colin
Are you sure you are getting the correct path and filename from the sheet every time?
How are you actually getting them?
hi norie
ive gone to sheet ive hyperlinked the path and tried the link ,then typed in the path as well and when run program it did not recognise it,once it said unknown file flashed up picture then said unknown file again
cheers colin
hi
ive just looked at this version and whatever you pick says does not exist
cheers colin
Why have you hyperlinked?
Just put the full path and filename in the cell, not just the filename.
Without the path VBA will look for the image file in the current directory, whatever that is.
Also, if the files are on a network drive you might want to look at using the UNC address.
hi
all works after all that it was the path as you had said earlier,not entered properly by me
many thabks to you for sticking with it
thankyou colin
Hi Colin
Thank you for the feedback! And for the rep also, the credits have to go to Norie!He/She offered a very nice example and it works excellent.
Cheers!
hi
gave rep to both of you for last 2 threads
cheers colin
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks