Solved Attach to changing Excel document

CJvdM

New Member
Hi,

I am currently experiencing an issue, where my application is generating an excel document which is not always standard (for eg WorkFile_20180118.xlsx). So a part of the name of the file being opened on screen changes.
I'm trying to get Blue Prism to attach to this temporary open document to read information and then close the open excel session.
However, in attaching, and then showing functions in the Excel VBO, I cannot specify a wildcard, for eg WorkFile_*.xlsx to grab the open document. When I also try to show what is currently attached, Blue Prism opens a blank new excel document.

Is there something I am missing, or is it somehow possible for BP to attach to an externally opened excel file with a name that constantly changes?
Any suggestions are welcome.

Thanks
 

CJvdM

New Member
I did yes. However on any Get* VBO function it requires Workbook/Worksheet name, which changes each time the file is opened.
 

CJvdM

New Member
You are right, it only requires handle it runs without any input, but after running still leaves collection as empty.
2018-01-12_18-22-44.jpg
 

CJvdM

New Member
My file looks like this, and its also the only excel workbook currently open. (values blacked out)

2018-01-12_18-31-57.jpg
 

tgundhus

Member
@CJvdM try to combine "Attach" and "Activate worksheet", you can use them both without defining any values in the action stages as long as you only have one "excel.exe" instance running?

Eg. try to open a new excel instance, write something in column "A1", then create a process using attach -> activate worksheet -> get cell values from BP's Excel VBO, the only thing you need to define is the column A1 in the get cell value stage. Should be working ;)
 

CJvdM

New Member
Aha, some success is to be had after playing with it a bit, and realising you don't have to specify the Workbook name.

2018-01-12_18-44-42.jpg

Out of curiousity. Is it possible for you to explain the scenario where multiple instances are running? Or in this case do you just cycle through the handles? Is there a function to obtain all handles for open instances?
 

CJvdM

New Member
So I've realised where the initial problem is coming from, and have tried numerous ways of attach, activate and shows without any success.
While I was testing the above just to get the functions working, I opened the excel file from Desktop, then run BP and it attaches 100% and everything works as it should.

Replicating my initial scenario, the excel file is opened from IE. The website generates a report in excel format, and then IE gives the option to Open the excel file and displays it on screen. (Normal IE Open, Save As, etc popup).

The problem I am having is attaching to this excel instance, as opening it from desktop works fine. However, even thought this is the only instance of excel now open, when using the "Attach" function, and any subsequent action (ie, Show, Read Cell, etc) launches a new instance of excel in the background (I can see this happening in Task Manager) and in reading empty cells, or until I use Show from Excel VBO, which displays the black new excel instance it created.

So I'm stuck again at wondering how to attach to the excel instance IE launches, as it appears to function differently that just normally launching a file from Desktop.

I appreciate any help and advise, as I realise this can be a bit tricky to easily replicate, as most people wont easily have access to a website which throws an excel file to open from IE.
 

RDawson9

Geek
Staff member
Hi @CJvdM

The predefined "Attach" and "Attach to workbook" actions in the Excel VBO are a bit misleading as they will both always generate a new instance of Excel.

Rather than trying to attach to the workbook, would this be a viable solution?

1) Instead of opening the workbook directly from IE, could you use the Save As feature instead?
2) Use the Excel VBO to open the file from it's saved location
3) Perform your desired task(s)
4) Delete the file from it's location to reduce a build up of files (if necessary)

A benefit of this method is that, if something goes wrong during the Excel processing and Excel needed to terminate for whatever reason, you still have the file available in the location you saved it, rather than having to relaunch IE and open the file again.
 

CJvdM

New Member
Hi @RDawson9 ,

Thanks for your reply, and I suppose I agree there more benefits to your method which is what I will be looking at implementing.
I guess I got stuck on the fact that the actual name of the excel document changes each time as well, not realising I can save it with whatever name I want using the Save As option instead.
 

rpadev1

New Member
Hi @RDawson9

For my scenario, I need to attach to existing web application for which logon is already done and available on Citrix desktop. I have observed that screen which I need to attach doesnt have any url and looks like Windows form. However when i check in Task manager, I can see this Window under Internet explorer of Processes(Task manager). I had given the Windows title/ Screen title in Attach properties. But it still doesnt get attached and fails.
 

RDawson9

Geek
Staff member
Hi @rpadev1

If this is automation of a Citrix desktop then you’ll need to use Surface Automation techniques, meaning you can only attach to Citrix itself and not the applications within it.
 

NissankaW

New Member
Hi @CJvdM

The predefined "Attach" and "Attach to workbook" actions in the Excel VBO are a bit misleading as they will both always generate a new instance of Excel.

Rather than trying to attach to the workbook, would this be a viable solution?

1) Instead of opening the workbook directly from IE, could you use the Save As feature instead?
2) Use the Excel VBO to open the file from it's saved location
3) Perform your desired task(s)
4) Delete the file from it's location to reduce a build up of files (if necessary)

A benefit of this method is that, if something goes wrong during the Excel processing and Excel needed to terminate for whatever reason, you still have the file available in the location you saved it, rather than having to relaunch IE and open the file again.

I had an issue with a Java application whose tables were not being spied. The tables can be opened as Excel files however. Eventually your suggested way was the only one that worked out. Thanks!
 

salrathor1

New Member
Hi All

I had a similar issue when opening an excel document.

When stepping through it would work fine but when running the process it wasn't taking the data or closing the instance etc. It's important to add a wait or sleep stage after the attach.
 
Top