I have a process in Excel that adds images from a PDF file with the following code:
valRef = "TabName"
FilePath = "\\network\file.pdf"
' Process stops in the next line
Worksheets(valRef).OLEObjects.Add Filename:=FilePath, Link:=False, DisplayAsIcon:=False
Some times, the process stops when adding the PDF file with the error 'Run-time error '1004' Cannot insert object
When the debug window comes up, I can press F5 and the process continues. The PDF file exists and with the same file, in the same network location, some times works without stopping.
Any ideas on how to prevent the process to stop?