Unable to run excel script using excel recorder activity

I am facing issues while running the excel script. I have added the vb code for renaming and copying file but its doesn’t work in RPA excel scripts. It working in other process.

I tried to test it with excel macro then it works fine issue with the RPA script for excel recorder.

So to avoid script i used file operation activity but got some error" illegal path characters." Attaching the screen shot about same.
My source path will be like -“C:\Users” & Environ$(“username”) & “\Downloads\ALCON*.xlsx”

Please help me with this issue asap.


Hi @shraddha08 ,

I am assuming you have only or more excel file to copy and rename based on pattern which starts with ALCON.
I am not sure why VB script is giving error to you.

There are several other ways to make it work -
→ Using File Search & File Operation Activity (Includes Excel Loop)
→ Using PowershellActivity (Simple & Starightforward)

  1. Solution for File Search & File Operation Activity

First, you’ll have to use File Search to search for file with pattern.
For File Search, your source path will be formed by assigning an argument with - “C:\Users”+Environment.Username+"\Downloads"

Your pattern can be “ALCON*.xlsx”

The output will be an excel file. You’ll have to iterate the Excel File using Excel loop and within it use File Operation Activity to Rename the file.

  1. Using Powershell

→ Command for Copying the files

Get-ChildItem “$HOME\Downloads” -Filter “ALCON*.xlsx” | Copy-Item -Destination “C:\DestinationPath”

→ Command for Renaming the files

Get-ChildItem “C:\SourcePath” ALCON*.xlsx | Rename-Item -NewName { $_.Name -replace ‘ALCON*’,‘NewFileName’ }

You can also use Python Script Activity as well if Python Environment is configured and you know it :slight_smile:

Thanks for the solution, it worked.