How to Get already opened Excel

excel
activities

#1

Hi Guys,
Is there any option how to get an excel workbook object which hasn’t been opened by UiPath?
My tool opens me a new excel with the report this excel isn’t saved on my PC. And I need to get some data form it.

BR,
Tomas


How to Get already opened Excel #2
#2

Hi TomasH

if you wants to access or read or write within a already opened excel then you can use Excel Scope Activity to deal with it. It will allow you to perform operation on that particular file in background if it is opened.

In case of any issues, Let me know.

Happy Learning Uipath :slight_smile:

Regards
Akshay


#3

Hi folks,

i was searching a method to delete a current row i am selecting from an excel, but send hotkey is not working, ( i try this within a for each ) and i also try with remove data row, putting the datatable var from the for each, but it says : None of the overload groups have all their required/optional activity arguments configured. My intention is deleting the current row, moving the rows up ( like ctrl - ).

i will try to explain better

1 excel application scope -> properties -> WorkbookPath = excel_path_var
2 inside excel application scope :
read range
properties ->
Range= ""
Sheetname = "Sheet1"
Output = currentRow

3 for each row -> body with operations

and here is where i want to remove the current file and shift cells up, for this i put remove data row passing
currentRow var to input -> DataTable

please could you give me a hand?

million of thanks in advance.


#4

Hey @aksh1yadav,
could you explain how exactly did you mean this advise? I have a similar problem and would like to read the range of cells of an already opened excel file. I read each excel sheet of the excel file and I would like to copy a range of cells from each sheet in another (existing) excel file which is in fact a pattern for all the copied sheets.

But the read range activity only works within an excel application scope activity. But there I have to insert a workbook path. But I want to read the already opened and active sheet without entering the workbook path because it could be dynamic. The Excel Scope Activity which you mentioned I cannot find or I didn’t get how it was meant.

Best regards
Johannes


#5

Well @Johannes
Excel application scope will deal with excel files without to open them and it is better way to do it.

Yes it will be easy just use read range activity and pass your specific range to read and again use Excel scope to generate new excel file and pass your read range return data to it with write range activity.

Yes you have to pass the path. it will be dynamic then use more advance thing to read a particular directory where your excel files will be exists or already exists :slight_smile:

Just search the form about how to read files from directory and then you will find plenty of examples just select as per your needs and give it a try :slight_smile:

This will be fast and reliable approach as well as per comparison with GUI Automation in terms of reliability and robustness.

Regards…!!
Aksh


#6

Thanks for your quick response. It helped me a bit but I think I started another approach based on your example from here:

So based on this case I got the sheet names and I played a bit with it. I gave out all sheet names and so on. But furthermore if I already got each of the sheet, I would like to get also a special range of cells within the sheet and copy it. But there is the missing part. I don’t know how to implement this get range (especially in this case here).

An Overview what I did:

  • read given path to get the files within the folder with directoryinfo()
  • Afterwards a Sequence a bit shortened:
  • For Each files in VarDirectory.GetFiles
  • Assign --> VarFileName = files.Name
  • Excel Application Scope --> Workbook path VarFileName / Output: VarWorkbookname
  • After Excel Application Scope a separate activity --> For Each Sheet in VarWorkbookname
  • Log Message with info: “Sheetname” --> Just to see that it worked (it works)

But instead of a log message I would like to have a read range activity now. But therefore I have to use a new excel application scope when I understand it right and according to this I have to open the excel file again what I don’t want because it is already open.

And if I would implement the read range activity within the Excel application scope above, I only would get the range of the first sheet1 because it is not dynamic isn’t it?

I guess I’m thinking quite difficult at the moment and have a node in my minds and probably it’s quite easy. :see_no_evil: So I’m happy about an advice. :slight_smile:


#7

Yes That is why you can use Existing opened Excel.

You just have to pass your Workbook application object to next excel application scope “ExistingWorkbook” option to use the same without pass the filename again.

For your reference:

Regards…!!
Aksh


#8

Hello,

I’ve a similar issue and I don’t think it can be sorted out through Excel Application Scope. Point is my application is opening a read-only excel file that’s not really saved anywhere in the local machine.In turn, I cannot retrieve the WB variable.

So, is there any way I can attach to the open workbook and use read range?

Thanks a lot!
Nicolò