Open Excel in specific folder/Directory and rename the file with current month

Hi fnds,

how to Open Excel in specific folder/Directory and rename the file with current month

Thanks in advance!

Venkatesh

2 Likes

Just try using Move file activity and give the name as

Now.ToString(“Mon”)+".xlsx"

or write a piece of VB code in Invoke Code Activity and Open the excel and use save as

  Dim excel As Microsoft.Office.Interop.Excel.Application
    Dim wb As Microsoft.Office.Interop.Excel.Workbook
wb = excel.Workbooks.Open("D:\2.28.2019 Feb 2019 Revenue Report.xlsx", [ReadOnly]:=False) 'Open the excel the file' 'Open the excel the file'
    excel.Visible = True
  wb.SaveAs("D:\" + DateTime.Now.ToString("MMMM") + ".xlsx")
    wb.Close()
    excel.Quit()
1 Like

Hii,

Generally im new to UIpath bro…started implementing in proj

where we write all this VB script in Notepad/studio :frowning:

Invoke Code activity and paste the above code changing the path bro @venkateshtangudu

No worries, here to help :slight_smile:

image

2 Likes

if you are new t0 Uipath
then try first option as suggest @HareeshMR

Thanks

2 Likes

Hi @venkateshtangudu

Use files =Directory.GetFiles(input path)
For each item in files
Use excel.application scope
Item.tostring
Use Move file
Thanks
Ashwin.S

Simple buddy
–use a assign activity like this
out_filepatharray = Directory.GetFiles(“yourfolderpath”,"*.xlsx")
where out_filepatharray is a variable of type array string
–then use For each loop and pass the above variable as input and change the type argument of for each loop as string
–inside the for each loop use a activity called Move File activity where in the source file path mention as item, the variable from for each loop that has the file path of the one we want to replace the name with current month
–and in the destination path mention like this buddy
item.Replace(",xlsx","")+"_"+Now.ToString(“MMMM”)+".xlsx"

now the file will be with current month at the end of the file name
Thats all buddy you are done
Kindly try this and let know for any queries or clarification
Cheers @venkateshtangudu

2 Likes

i will try and let you know

1 Like

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