Karthik Thandapani
Member
Hi @Hui / experts:
http://forum.chandoo.org/threads/vba-snippet-to-attach-an-image.19404/#post-116937
above link helps to attach an image and to fit in a particular range. I am seeking help to expand the below code a bit to suit my another requirement.
a) I have image files saved in a particular folder. By default pic1 should load into range("A1:H20")
b) Can we have next button at right and previous button in the other side so as soon as we click, that deletes the existing image file and loads the next?
Please help. Thanks!
http://forum.chandoo.org/threads/vba-snippet-to-attach-an-image.19404/#post-116937
above link helps to attach an image and to fit in a particular range. I am seeking help to expand the below code a bit to suit my another requirement.
Code:
Sub InsertImage()
Dim myFilePath As String
myFilePath = RetrieveFileName
If myFilePath = "" Then Exit Sub 'User cancelled
ActiveSheet.Shapes.AddPicture myFilePath, False, True, Range("A1").Left, Range("A1").Top, Range("A1:H20").Width, Range("A1:H20").Height
End Sub
Private Function RetrieveFileName()
'obtained from:
'http://www.ozgrid.com/VBA/ExcelsDialogBoxes.htm
Const myFilter As String = "Any Files (*.*),*.*"
Dim sFileName As String
'Change current folder to be wherever this file is stored
ChDir ThisWorkbook.Path
'Show the open dialog and pass the selected file name to the String variable "sFileName"
sFileName = Application.GetOpenFilename(FileFilter:=myFilter, Title:="Picture Select", MultiSelect:=False)
'They have cancelled.
If sFileName = "False" Then Exit Function
RetrieveFileName = sFileName
End Function
a) I have image files saved in a particular folder. By default pic1 should load into range("A1:H20")
b) Can we have next button at right and previous button in the other side so as soon as we click, that deletes the existing image file and loads the next?
Please help. Thanks!