Forum Discussion
Re: Load Image from path into Image ActiveX Control in worksheet
The code fails to do what you want because you ALWAYS call hideshapes after showshapes. So shapes were displayed briefly, then hidden again.
I have sent the file back by PM.
66 Replies
- MuhammadiyyaBrass ContributorDid you mean you have sent it or you will send it?
You should have received a reply to your private message, with the file attached.
- MuhammadiyyaBrass ContributorHy, I don't know why the macro below isn't running.
Sub SaveStudentInfo()
Dim wsForm As Worksheet
Dim wsBioData As Worksheet
Dim lastRow As Long
Dim regNo As String
Dim name As String
Dim email As String
Dim imagePath As String
Dim shp As Shape
' Set the worksheets
Set wsForm = ThisWorkbook.Sheets("Form")
Set wsBioData = ThisWorkbook.Sheets("BioData")
' Get the entered information
regNo = wsForm.Range("A1").Value
name = wsForm.Range("B1").Value
email = wsForm.Range("C1").Value
' Get the image path
On Error Resume Next
Set shp = wsForm.Shapes("STDPICS")
On Error GoTo 0
If shp Is Nothing Then
MsgBox "Shape 'STDPICS' not found in the 'Form' sheet."
Exit Sub
End If
imagePath = shp.LinkFormat.SourceFullName
' Find the last row in BioData sheet
lastRow = wsBioData.Cells(wsBioData.Rows.Count, 1).End(xlUp).Row + 1
' Save the data to BioData sheet
wsBioData.Cells(lastRow, 1).Value = regNo
wsBioData.Cells(lastRow, 2).Value = name
wsBioData.Cells(lastRow, 3).Value = email
wsBioData.Cells(lastRow, 4).Value = imagePath
End Sub
I want to save students info into a sheet(JSS2BD, the line where I declared the imagepath isn't running