Able to read range workbook without error?

Dear all, i’m trying to write a bot that will run excel, multiple worksheets.
on each worksheet, to copy a particular range then add into a data table.

so after i realised how difficult it is to read sheet name, i did a keyboard shortcuts instead. However i encounter error when i read range workbook because i was opening the workbook. (Which i needed as it is a VSTO file (like system) in order to run the worksheets). Help! Appreciate for any help!
(i even tried using Use Excel etc. but i encounter another set of errors.) T_T

image

@winnie_toh
close the excel file you are trying to read and run it again

Regards,

Hi,

Can you tr to use the following ReadRange (red arrow) with UseExcelFile activity?

image

If you have an exception, can you share it?

Regards,

Hey @winnie_toh ,
Before reading each sheet use Kill process activity
image

@winnie_toh

The error you got is your excel file is opened when you are running, Close the excel and run the excel file.

To read Multiple Sheet Names:
In excel application scope:
Use For each execl Sheet
Use:currentSheet.Name
This gives the current sheet name

Using For each excel sheet you can loop through each excel sheet

Hello @winnie_toh ,
When you are using Using Workbook Activities like Read Range WOrkbook, The Excel Files should not be open, So close all the Excel Files and then try using the Activity.
THe Alternate way is to use the Modern Excel Activities :


Hope this Helps you.
Regards;)

hi as i need the excel file to be open in order to run multiple worksheets (it is a system excel VSTO file)
i tried using this but this is what i get when i try to input range. T_T

image

Hi,

Can you try as the following?

Excel.Sheet("Sheet1").Range("A5:E1000")

Regards,

Hello @winnie_toh Try using this:


I hope this helps.
Regards;)

hi @winnie_toh ,
your file used by other process
you need kill excel process before use read range this file
regards,
LNV

@winnie_toh

  1. To get all sheetnames you can use get worksheets activity from The classic activities (Activities → filter icon-> classic)
  2. You can also use for each sheet in excel activity which is available in modern which will repeat for each sheet

For the second option

  1. Drag a use excel file activity and provide the file details as you are only using read…from properties you can check readonly property
  2. Now inside use excel drag a for each sheet in excel activity
  3. Inside the loop use your read range with Excel.Sheet(currentSheet).Range("A5:E1000")

Hope this helps

Cheers

Thank you also to @Yoichi
Yes i tried that before, but unfortunately i encountered below error:

Hey @winnie_toh ,
Try this and check

Hi,

For now, can you try it to put Shortcut activity to send ESC before ReadRange?

OR, in many case, it’s unnecessary to use shortcut. I guess you tried to get Sheet name before ReadRange. However we might be able to get each sheet name using ForEachExcelsheet or Classic Get Workbook Sheets activity.
So, first, can you try to remove shortcut and set sheet name statically, then check if solve this issue. If it’s solved, try to get sheet name dynamically.

Regards,

1 Like

Hello @winnie_toh ,
Are you using the Modern Read Range Activity inside the ‘Use Excel File Activity’?


Regards;)

Thank you all so much for your help!! so silly of me, the reason of the error is indeed due to the mouse cursor was still at the worksheet. XD
Thank you so much!!

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.