VBA embed object/file into specific column of excel
I have a piece of code (code is not mine) for embedding file into a specific column, but i couldn't figure out a way to modify as i constantly a wrong syntax. I'm trying to make it prompt user to choose a file to embed inside the worksheet. but this code is referring to objects in the workbook path
Private Sub CommandButton2_Click() Application.ScreenUpdating = False Dim cell As Range ' loop each cell in column B For Each cell In Range("B3:B" & Range("B" & Rows.Count).End(xlUp).Row) ' make sure the cell is NOT empty before doing any work If Not IsEmpty(cell) Then ' create and insert a new OleObject based on the path Dim ol As OLEObject Set ol = ActiveSheet.OLEObjects.Add( _ Filename:=ActiveWorkbook.Path & "\" & cell, _ Link:=True, _ DisplayAsIcon:=True, _ Height:=10) ' align the OleObject with Column D - (0 rows, 3 columns to the right from column A) With ol .Top = cell.Offset(0, 3).Top .Left = cell.Offset(0, 3).Left End With End If Next Application.ScreenUpdating = True End Sub
I'm still new VBA programming. I'd be glad if anyone could help me with this situation.