BROWSE AN IMAGE from hardisk an past to excel

  • Thread starter Thread starter Disperso
  • Start date Start date
D

Disperso

my .xls must be simply a foto and a button "browse".
I want that i can browse a photo from hardisk and, when i selected, it
appear
on document.

Can you help me?

thx
 
Try this Disperso

MyPath = "C:\"
Change this to your path


Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = "C:\"
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:= _
"Pictures(*.jpg;*.gif;*.bmp), *.jpg;*.gif;*.bmp")

If FName <> False Then
ActiveSheet.Shapes.AddPicture FName, msoTrue, _
msoFalse, 100, 100, 100, 50
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub
 
wow it function!

before thanking you, if possibile i want to add a variant:

i click a button for browse a file on mypath1.
the file that i've select will be writed, without extension, on a cell (only
the name of file) (now i call it %file%)
At same time, will be automatically paste an image from mypath2 (another
custom path) %file%.jpg
and another image from mypath3 V2_%file%.jpg
Example of result is this:
i'm browsing a file called "foto1.kkk";
after selected, the name "foto1" appear on a cell and will be loaded an
image foto1.jpg (from mypath2) and V2_foto1.jpg
from mypath3

Excuse for this request, I am note studying Excel ;)

thank you very much

Ron de Bruin said:
Try this Disperso

MyPath = "C:\"
Change this to your path


Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = "C:\"
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:= _
"Pictures(*.jpg;*.gif;*.bmp), *.jpg;*.gif;*.bmp")
 
You can use this to get only the file name

Dim filename As String
filename = Left(Dir(FName), Len(Dir(FName)) - 4)
MsgBox filename


You can use filename in your other code then
 
Back
Top