designtime
New Member
- Joined
- May 25, 2012
- Messages
- 1
Hi all,
Firstly i'm a design student using excel to make a prototype of an interface using excel. My knowledge of VB and macros is next to nothing so please forgive any ignorance on my part. I've managed to bungle several strings of code i've found in forums together to accomplish a desired task, but it seems to be having issues.
I need to import multiple images from a predetermined folder into column A, with each image in a separate cell. I need to do this on multiple sheets. The problem i'm having is that every time i save the document and re-open it, i have to enable the macro option and it seems to repeat the function; re-importing the images onto whatever sheet i have open at the time and overlaying multiple images on top of each other.
Here is the code i used:
Function ShowPic(PicFile As String) As Boolean
Dim AC As Range
On Error GoTo Done
Set AC = Application.Caller
Set p = ActiveSheet.Pictures.Insert(PicFile)
With Application.Caller
t = .Top + 8
l = .Left + 4
w = (.Offset(0, .Columns.Count).Left - .Left) * 0.95
End With
' position picture
With p
.Top = t
.Left = l
.Width = w
End With
Set p = Nothing
'ActiveSheet.Shapes.AddPicture PicFile, True, True, AC.Left, AC.Top, 106, 79
ShowPic = True
Exit Function
Done:
ShowPic = False
End Function
Please help! thanks in advance
Firstly i'm a design student using excel to make a prototype of an interface using excel. My knowledge of VB and macros is next to nothing so please forgive any ignorance on my part. I've managed to bungle several strings of code i've found in forums together to accomplish a desired task, but it seems to be having issues.
I need to import multiple images from a predetermined folder into column A, with each image in a separate cell. I need to do this on multiple sheets. The problem i'm having is that every time i save the document and re-open it, i have to enable the macro option and it seems to repeat the function; re-importing the images onto whatever sheet i have open at the time and overlaying multiple images on top of each other.
Here is the code i used:
Function ShowPic(PicFile As String) As Boolean
Dim AC As Range
On Error GoTo Done
Set AC = Application.Caller
Set p = ActiveSheet.Pictures.Insert(PicFile)
With Application.Caller
t = .Top + 8
l = .Left + 4
w = (.Offset(0, .Columns.Count).Left - .Left) * 0.95
End With
' position picture
With p
.Top = t
.Left = l
.Width = w
End With
Set p = Nothing
'ActiveSheet.Shapes.AddPicture PicFile, True, True, AC.Left, AC.Top, 106, 79
ShowPic = True
Exit Function
Done:
ShowPic = False
End Function
Please help! thanks in advance