How to close excel (Before execute macro)?

I want to close excel file in loop for each (item) before execute macro.
Main.xaml (14.3 KB)



My flow

  1. loop file in folder C:\Jess\Desktop\RPA\input\File
  2. keep path file in item
  3. keep sheet in item2
  4. write data item , item2 in file excel Reconcile Logic.xlsm
  5. run macro in file Reconcile Logic.xlsm
  6. go to step1 until loop in folder complete.

Please guide me about it.

Hi @fairymemay

How about using Close Workbook Activity!

Pass the Input as Workbook variable from excel application scope!

Regards

@pravin_calvin Use​ Close Workbook​ Activity​ after​ Activity?

Hi @fairymemay

At the End of the first excel application scope activity!

Regards

@fairymemay

Or Use Kill process by using process name as excel before starting the file !

Regards

@pravin_calvin NOW​ MY​ FLOW

LOOP FILE.(EXCEL SCOPE)​
EXCEL​ SCOPE​ (MACRO)

MACRO​ HAVE​ INSIDE EXCEL​ SCOPE.

Hi @fairymemay

As per my understanding you’re Appling macro on iterating files from folders right?

Regards

Hi @fairymemay ,

in my opinion Get visible sheets will provide all the sheets in string array i guess. in that case we can keep the second for each loop outside first excel application scope so you no need to use any close work book it will close automatically after extracting all the sheets from that excel. please try and let us know. thanks.

@pravin_calvin yes

Hi @fairymemay

Your steps would be a follows below!

For each item in directory.GetFiles(YourPath)

Excel application Scope(item.toString)

Do

Get Visible sheets(Item.toStriing)

For each item2 in visiblesheets

If(Your Condition)

Then

Write cell sheet name Item2
write cell sheet name Item2

Execute macro

Close work book!

Regards

1 Like

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