I'm fairly new to VBA, have been trying to work this one out but not having any luck.
I'm trying to create a product catalogue and have built a userform to allow new products to be entered on the first blank row of the spreadsheet. So far so good.
Where I'm getting stuck however, is that I need to embed a product image from a url in the userform (e.g. https://image.shutterstock.com/z/stock-photo-coffee-cup-and-coffee-beans-on-table-261745823.jpg) so that the file is able to be ported from computer to computer without losing the images already loaded onto the spreadsheet.
Ideally I don't want to have to insert the URL itself onto the spreadsheet at all. When the user hits Submit, I want the userform to pull the image from online & insert it into column A on the first blank row of the spreadsheet & resize it to a particular width/height. (to be determined).
I've found questions kind of similar to what I need here & here & here. The questions either aren't answered, or I'm not sure how to make them fit my needs.
This is the code I have now, however it presents a runtime 424 object error, I've clearly missed something ><
Private Sub cmdSubmitForm_Click()
Dim StorePrice As Currency, SupplierPrice As Currency
Dim pic As String 'file path of pic
Dim LastRow As Long, ws As Worksheet
Set ws = Sheets("Pricing")
'Finds the last blank row
LastRow = ws.Range("B" & Rows.Count).End(xlUp).Row + 1
StorePrice = txtStorePrice.value
SupplierPrice= txtSupplier.Price.Value
ws.Range("B" & LastRow).Value = txtProductName.Text
ws.Range("C" & LastRow).Value = txtStorePrice.Text
ws.Range("D" & LastRow).Value = cboCategory.Text
ws.Range("E" & LastRow).Value = cboSubCategory.Text
ws.Range("F" & LastRow).Value = txtStoreLink.Text
ws.Range("G" & LastRow).Value = txtSupplierName.text
ws.Range("H" & LastRow).Value = txtSupplierPrice.text
ws.Range("I" & LastRow).Value = txtSupplierLink.text
ws.Range("J" & LastRow).Value = StorePrice- SupplierPrice
ws.Range("K" & LastRow).Value = txtNotes.Text
ws.Range("A" & LastRow).Value = Pictures.Insert(txtImgUrl.Value)
'handler:
'MsgBox "Error"
End Sub
If anyone has any ideas on how to solve this I would really appreciate it!!!!
Thanks in advance :)