Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Can't rename file in a loop

The problem I am trying to resolve is to print several different documents to PDF files, and then merge them into one PDF file.


My method:

With PDF Printer as the default printer, I set up a loop for Word files, and one for Excel files.

Within each loop, for each CurrentItem, I get the file path name (to name the interim PDF file), and rename each file to one consistent name (e.g., ToPrint.docx or ToPrint.xlsx) so that I can populate the interim filename and save the interim files via the UI element with the same Word and Excel windows 


However, after the first run of the loop, I cannot rename the file in the second run of the same loop.  The error message is "Can't rename file" because access to path of ToPrint.docx is denied.



Memorable Member
Memorable Member

You don't need to rename the files, just store the file name in a variable and use this in the selector to get the application window 

Frequent Visitor

Thanks for your advice.  However, I still have the following issue to resolve:


Let's say the files may be docx or xlsx or else.  If I have set the printer to PDF Printer, after "Print document", I will have to "Populate text field in window" for the "File name" text box.  How can I properly identify the window?

Memorable Member
Memorable Member

Normally it should be part of the selector, but you can also get or focus the window based on its title

Helpful resources

MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (987)