01-04-24 08:41 AM
Hello BP Experts,
I'm reaching out for guidance regarding arranging screenshots sequentially in Excel, each with specific height and width parameters.
Here's an example scenario: Navigate to a specific screen on SAP, capture the screenshot, paste it into Excel with designated height and width. Then, return to SAP, navigate to a different screen, capture another screenshot, and paste it next to the previous one in Excel.
I hope this requirement is clear. Your expertise on this matter would be invaluable. #SAP, #Excel
03-06-24 01:01 PM
I am running into the same requirement.
Was this already resolved?
03-06-24 05:15 PM - edited 03-06-24 05:18 PM
Hi @Niraj.kumar and @rey.saldua_db.com ,
Thanks for bringing this query up. It seems to have gone unanswered for quite a while so I am providing my inputs for the same.
Currently, I don't think there is any action to achieve this functionality in the current 'MS Excel - 10.3.0' VBO which has been posted in DX Exchange.
But you can achieve this functionality by extending either 'MS Excel' by creating a new action within the object.
NOTE: I would recommend create a duplicate object of these objects and make your changes there so that you always have a backup with you in case anything goes wrong.
Now, you need to create a new action in your already existing Excel VBO business object named 'Insert Image' and provide the following input parameters to your action:
handle: This is a number type data item which will hold the current session dictionary value.
workbookname : This is a text type data item where you need to pass the workbook name that you might get from 'Create Workbook' or 'Open Workbook' action.
worksheetname: This is a text type data item which indicates the name of the worksheet in your excel workbook file where you want to insert the image.
cellref: This is a text type data item which indicates the name of the worksheet in your excel workbook file where you want to insert the image.
imagefilepath: This is a text type data item which indicates the file path of the image that needs to be inserted.
imageheight: This is a number type data item which indicates the height dimension of the image to be inserted.
imagewidth: This is a number type data item which indicates the width dimension of the image to be inserted.
Now, you can add a page reference stage to the 'Activate Sheet' page and then add another code stage named 'Insert Image' and add the following inputs parameter and map the data items to it:
Add the following code under the Code tab:
Try
Dim worksheet As Object = GetWorksheet(handle, workbookname, worksheetname)
' Get the range for the cell reference
Dim cell As Object = worksheet.Range(cellref)
' Get the left and top position of the cell
Dim left As Double = cell.Left
Dim top As Double = cell.Top
' Add the picture to the worksheet
Dim pictures As Object = worksheet.Pictures
Dim pic As Object = pictures.Insert(imagefilepath)
' Set the picture properties
pic.Left = left
pic.Top = top
pic.Width = imagewidth
pic.Height = imageheight
' Clean up
ReleaseObject(pic)
ReleaseObject(pictures)
ReleaseObject(cell)
ReleaseObject(worksheet)
Catch ex As Exception
' Handle any exceptions
Throw New Exception("Error pasting screenshot: " & ex.Message)
End Try
You should have your workflow ready as shown below:
Now, publish your action and then use all the actions of the same business object where you have done the changes in your process studio while interacting with the excel file in order to avoid any exceptions. I have a sample process studio workflow shown below:
Here, I am creating an excel instance, then opening my excel file, then making it visible on the screen and then I use my new created action which has the below parameters:
As you can see my image got inserted with dimensions 600X700 starting from cell A25.
04-06-24 02:02 AM
Thanks devneetmohanty07 for the feedback.
Your solution is very informative and I think it will certainly work.
I applied another solution which is duplicating the "Paste" action and replacing the "pasteSpecial..." line by sheet.paste.