1
Is there a way you can set this code to have the embedded image go into a separate cell instead of on top of each other?
For example, i run this macro to insert 3 PDFs. I want these 3 PDFs to go in cells A2, A3, A4.
The reason I am doing this is because I am going to use this spreadsheet in a mail merge to send the individual PDFs to different email addresses.
Sub AddOlEObject()
Dim mainWorkBook As Workbook
Set mainWorkBook = ActiveWorkbook
Folderpath = "C:\Users\jyousef\Documents\SL\October15"
Set fso = CreateObject("Scripting.FileSystemObject")
NoOfFiles = fso.GetFolder(Folderpath).Files.Count
Set listfiles = fso.GetFolder(Folderpath).Files
For Each fls In listfiles
Counter = Counter + 1
Range("A" & Counter).Value = fls.Name
strCompFilePath = Folderpath & "\" & Trim(fls.Name)
If strCompFilePath <> "" Then
ActiveSheet.OLEObjects.Add(Filename:=strCompFilePath, Link:=False, DisplayAsIcon:=True, IconIndex:=1, IconLabel:=strCompFilePath).Select
'Sheets("Object").Activate
'Sheets("Object").Range("B" & ((Counter - 1) * 3) + 1).Select
End If
Next
mainWorkBook.Save
End Sub
Please provide the macro you are using. – gtwebb – 2016-08-16T23:15:51.363
I pasted the code in my post. I found this code from a previous post titled "Is it possible to insert multiple objects at once in Excel 2007?" – JAY – 2016-08-17T14:51:23.443