Macro to insert picture from specific folder

Joined
Mar 18, 2015
Messages
1
Reaction score
0
I am currently trying to run a macro to insert a picture from a specif file into a specif cell (B8).
However, when I click on the macro button, it opens an "OPEN" dialog box where I can select a picture to insert ... but it's not the proper folder.
Does anyone know how I could modify the code to make it open the dialog box for a specific Picture folder (L:\ACCESS\Pics) so that I can select my picture to insert ?

Here is the code:


Sub Insert_N_Pict()
Dim oPict, PictObj
Dim sImgFileFormat As String
Dim rPictCell As Range
Dim iAns As Integer

sImgFileFormat = "jpg Files (*.jpg), *.jpg, bmp (*.bmp),*.bmp,tif (*.tif),*tif"

ActiveSheet.Range("B8").Select

GetPict:
oPict = Application.GetOpenFilename(sImgFileFormat)
If oPict = False Then End

iAns = MsgBox("Open : " & oPict, vbYesNo, "Insert Picture")
If iAns = vbNo Then GoTo GetPict

Set PictObj = ActiveSheet.Pictures.Insert(oPict)

With PictObj
.ShapeRange.LockAspectRatio = msoTrue
.ShapeRange.Height = 255#
End With

Set PictObj = Nothing
Set rPictCell = Nothing

End Sub



Thanks your help would be greatly appreciated
 
Back
Top