How to rename the excel sheet without using the copy or move activity

Hello Smart People

i would like to rename the file name by adding the yyyymmddhhmm to its original file name .
eg: example.xlsx to example202009281050.xlsx

I follow this link Rename an excel file without moving the file

And i ONLY wrote in the edit code as follow
Where do i need to fix it and do i need to write something in the invoke code property ?
Thank you very much

Hi @eimon invoke code language is VBNet and in the edit code put
FileSystem.Rename(“C:\Ui\RPA\OUTPUT\Example_.xlsx”,“C:\Ui\RPA\OUTPUT\Example_" & Now.ToString("yyyyMMddhhmm”) & “.xlsx”)

Hello averjr
Thank you for the reply. But it still throws the exception.
Like this : Invoke code :Exception has been thrown by the target of invocation. do i need to make something in its property

Thank again

I have not done anything special in my test code and it works fine…

Would you mind sharing your *.xaml file? I’ll have a look

Hello averjr
Thank you for the quick reply. When i tested only invoke actvity in other work flow, it works as you say.

But in my actual work flow, before the invoke step , i use the copy sheet actvitiy . I know the file can rename with that copy sheet actvity .


Hello again @eimon, I am not sure but it is nice if you can check if the excel file you are trying to rename is not open as it looks like there is an excel application scope after your copy sheet which is using the new file. You can use “close workbook” or “close application” then add some delay then you can go with the invoke code to rename

Hello Dear avejr
Thank you so so much .YES,finally it works .Yayy!
I hope you enjoy your time and happy.
Best wishes

1 Like

You’re welcome @eimon
I’m glad I have been able to help you. :slight_smile:

1 Like

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