Hello,
Could anyone help me if possible with a VBA Code that inserts a .jpeg file from a 2 folders. To be more specific something like this :
Main Folder path: D:\Paul\Proiect fluturi\Cercetare\LEPIDOPERA DATA BASE\Plante gazda
The second folder \Ballota nigra ( is latin name of a plant) is part of Plante gazda folder .
The main cell value= "Plante gazda" Folder
The second cell will contain the .jpeg file name that need to be inserted in the Database
As exemple in Cell A1= Corn = Folder name --> the code must chose the folder by the A1 reference
in Cell A2= Pic1, Pic2, Pic3..... ( I will select it from a Data Validation list) = .jpeg file name --> the code must chose the file based on Cell A2 reference an inser the picture
Because this is a Database this must be dynamic, if search for another species and select another file it must delete the previous one.
As a note I am using a similar code that inserts a picture based only a cell value that equals with the .jpeg file name and it looks like this
Sub View_Picture() Dim myObj Dim Pictur Set myObj = ActiveSheet.DrawingObjects For Each Pictur In myObj If Left(Pictur.Name, 7) = "Picture" Then Pictur.Select Pictur.Delete End If Next Dim NumeFluture As String, T As String myDir = "D:\Paul\Proiect fluturi\Cercetare\Foto in habitatul natural\" NumeFluture = Range("D5") T = ".jpg" On Error GoTo errormessage: ActiveSheet.Shapes.AddPicture Filename:=myDir & NumeFluture & T, linktofile:=msoFalse, savewithdocument:=msoTrue, Left:=700, Top:=40, Width:=700, Height:=700 errormessage: If Err.Number = 1004 Then MsgBox "Lipsa imagine" & vbCr Range("C52").Value = "" End If End Sub
Bookmarks