Now I am stuck again. Does anyone know how to transfer the excel vba to access vba? Now the Excel macro will run after clicking on an icon. It would be nice if I could have access to do the job. Please help transfer to access vba code.
Code:
Option Explicit
Sub Picture1_Click()
Dim pictureNameColumn As String 'column where picture name is found
Dim picturePasteColumn As String 'column where picture is to be pasted
Dim picturePath As String 'picture name
Dim lastPictureRow As Long 'last row in use where picture names are
Dim pictureRow As Long 'current picture row to be processed
pictureNameColumn = "E"
picturePasteColumn = "A"
pictureRow = 10 'starts from this row
'find row of the last cell in use in the column where picture names are
lastPictureRow = Cells(Rows.Count, pictureNameColumn).End(xlUp).Row
'stop screen updates while macro is running
Application.ScreenUpdating = False
'loop till last row
Do While (pictureRow <= lastPictureRow)
picturePath = Cells(pictureRow, "E") 'This is the picture name
'if picture name is not blank then
If (picturePath <> vbNullString) Then
'check if pic is present
If (Dir(picturePath) <> vbNullString) Then
Cells(pictureRow, picturePasteColumn).Select 'This is where picture will be inserted
ActiveSheet.Pictures.Insert(picturePath).Select 'Path to where pictures are stored
With Selection
.Left = Cells(pictureRow, picturePasteColumn).Left
.Top = Cells(pictureRow, picturePasteColumn).Top
.ShapeRange.LockAspectRatio = msoTrue
.ShapeRange.Height = 150#
.ShapeRange.Width = Cells(pictureRow, picturePasteColumn).Width
.ShapeRange.Rotation = 0#
End With
Else
'picture name was there, but no such picture
Cells(pictureRow, picturePasteColumn) = "No Picture Found"
End If
Else
'picture name cell was blank
End If
'increment row count
pictureRow = pictureRow + 1
Loop
Range("A10").Select
Application.ScreenUpdating = True
Exit Sub
End Sub
Thank you experts. Your input really helped me a lot!