yesterday
Hello.
I am trying to embed PDF as an OLE object in Excel via Blue Prism. Any leads would be helpful. Thanks in advance for your time and suggestions.
I am using regular Excel object to create instance, open workbook, activating required worksheet and then attempting to add PDF file using the below code but getting error as “Add method of OLEObjects class failed”
Tested with the ClassType:= “Acrobat.Document.DC” as well
Dim excelApp As Object
Dim workSheet As Object
Dim range As Object
Dim pdfPath As String
excelApp = GetInstance(Handle)
workSheet = excelApp.ActiveSheet
pdfPath = "C:\path\file.pdf"
range = workSheet.Range(“A1”)
workSheet.OLEObjects.Add( _
ClassType:="AcroExch.Document", _
FileName:=pdfPath, _
Link:=False, _
DisplayAsIcon:=True, _
IconLabel:="Embedded PDF")
Thanks,
Answered! Go to Answer.
yesterday
Hi @RachanaA ,
You can try the following approach in a separate action page in your business object:
1) Create a business object named, 'Insert PDF' with following arguments:
2) Create a code stage with the following arguments and code:
Dim wb, excel, range As Object
Try
wb = GetWorkbook(Handle, Workbook)
excel = wb.Application
excel.ActiveSheet.OLEObjects.Add(Filename:=PDFFilePath, Link:=False, DisplayAsIcon:=True, IconFileName:=PDFApplicationPath, IconIndex:=0, IconLabel:="Passport.pdf")
Success = True
Catch e As Exception
Success = False
Message = e.Message
Finally
wb = Nothing
excel = Nothing
range = Nothing
End Try
3) Your workflow should look something like this:
4) Pass the proper arguments for the PDF file path which is your actual file path and your adobe application path and it should work as you can see below:
Let me know if you have any further doubts. Thanks for posting your query in the community.
yesterday
Hi @RachanaA ,
You can try the following approach in a separate action page in your business object:
1) Create a business object named, 'Insert PDF' with following arguments:
2) Create a code stage with the following arguments and code:
Dim wb, excel, range As Object
Try
wb = GetWorkbook(Handle, Workbook)
excel = wb.Application
excel.ActiveSheet.OLEObjects.Add(Filename:=PDFFilePath, Link:=False, DisplayAsIcon:=True, IconFileName:=PDFApplicationPath, IconIndex:=0, IconLabel:="Passport.pdf")
Success = True
Catch e As Exception
Success = False
Message = e.Message
Finally
wb = Nothing
excel = Nothing
range = Nothing
End Try
3) Your workflow should look something like this:
4) Pass the proper arguments for the PDF file path which is your actual file path and your adobe application path and it should work as you can see below:
Let me know if you have any further doubts. Thanks for posting your query in the community.
yesterday
@devneetmohanty07 Thank you so much. It worked.