cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mbeser
New Member

Modify a batch of word documents

Hello everyone.

 

I am new with Power Automate Desktop and i'm looking for a automation flow.

 

I have a document folder, which includes .ie 100 Word documents. In manually i need;

 

1. Open each word documents

2. Change the fonts ie Arial 12

3. Save the document.

 

Can i do this with power automate, without manual operations?


Thanks

5 ACCEPTED SOLUTIONS

Accepted Solutions
MichaelAnnis
Super User
Super User

Get Files

For each %CurrentItem% in Files

Launch Word Open:  %CurrentItem%

Use the Desktop Recorder to use the menu to Select All, Arial Font, size 12

Save and Close Word

End #For Each

View solution in original post

You could even use Save As instead of just Save, and save the new version to another folder, then delete the old version; that way if something goes wrong, you will know which ones are done and which ones aren't.

View solution in original post

Anonymous
Not applicable

Hello @mbeser 

 

You can use keyboard shortcut "Alt - H - FF" to focus into the combobox of font name in the ribbon of Word app.

 

Below is my sample flow that meets your requirement.

 

 

Folder.GetFiles Folder: $'''C:\\Users\\User01\\Documents\\Word Files''' FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
SET FontName TO $'''Verdana'''
SET FontSize TO 12
LOOP FOREACH CurrentItem IN Files
    System.RunApplication ApplicationPath: $'''C:\\Program Files\\Microsoft Office\\root\\Office16\\WINWORD.EXE''' CommandLineArguments: $'''/t \"%CurrentItem.FullName%\"''' WindowStyle: System.ProcessWindowStyle.Normal ProcessId=> AppProcessId
    WAIT (UIAutomation.Windows.ToOpenByTitleClass Title: $'''%CurrentItem.NameWithoutExtension%*''' Class: $'''''' FocusWindow: True)
    MouseAndKeyboard.SendKeys TextToSend: $'''{Control}({A})''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    MouseAndKeyboard.SendKeys TextToSend: $'''{Alt}(){H}{F}{F}%FontName%{Tab}%FontSize%{Tab}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    MouseAndKeyboard.SendKeys TextToSend: $'''{Alt}({F4}){Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
END

 

 

shindomo_4-1632315425373.png

Launch WINWORD.EXE application with /t switch to open your file.

 

shindomo_1-1632315322367.png


Wait until window of Word application which has your file name in title bar will open.

 

shindomo_2-1632315356188.png

 

Then send keys what ever as you like.

 

shindomo_3-1632315371095.png

 

Thank you.

View solution in original post

VJR
Super User
Super User

Hello @mbeser 

 

As per your note if you want to do it without manual operations then you can

- Write an Excel macro that changes the font of Word documents (tons of readymade code easily available on the web)

- And then call that macro from within PAD.

VJR_0-1632479061289.png






-------------------------------------------
Help fellow beings find relevant posts.
Upvote to a supporting response.
Mark as solution to an answer.

View solution in original post

@mbeser 

PS: I can help you with the macro in case you need.

View solution in original post

5 REPLIES 5
MichaelAnnis
Super User
Super User

Get Files

For each %CurrentItem% in Files

Launch Word Open:  %CurrentItem%

Use the Desktop Recorder to use the menu to Select All, Arial Font, size 12

Save and Close Word

End #For Each

You could even use Save As instead of just Save, and save the new version to another folder, then delete the old version; that way if something goes wrong, you will know which ones are done and which ones aren't.

Anonymous
Not applicable

Hello @mbeser 

 

You can use keyboard shortcut "Alt - H - FF" to focus into the combobox of font name in the ribbon of Word app.

 

Below is my sample flow that meets your requirement.

 

 

Folder.GetFiles Folder: $'''C:\\Users\\User01\\Documents\\Word Files''' FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
SET FontName TO $'''Verdana'''
SET FontSize TO 12
LOOP FOREACH CurrentItem IN Files
    System.RunApplication ApplicationPath: $'''C:\\Program Files\\Microsoft Office\\root\\Office16\\WINWORD.EXE''' CommandLineArguments: $'''/t \"%CurrentItem.FullName%\"''' WindowStyle: System.ProcessWindowStyle.Normal ProcessId=> AppProcessId
    WAIT (UIAutomation.Windows.ToOpenByTitleClass Title: $'''%CurrentItem.NameWithoutExtension%*''' Class: $'''''' FocusWindow: True)
    MouseAndKeyboard.SendKeys TextToSend: $'''{Control}({A})''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    MouseAndKeyboard.SendKeys TextToSend: $'''{Alt}(){H}{F}{F}%FontName%{Tab}%FontSize%{Tab}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    MouseAndKeyboard.SendKeys TextToSend: $'''{Alt}({F4}){Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
END

 

 

shindomo_4-1632315425373.png

Launch WINWORD.EXE application with /t switch to open your file.

 

shindomo_1-1632315322367.png


Wait until window of Word application which has your file name in title bar will open.

 

shindomo_2-1632315356188.png

 

Then send keys what ever as you like.

 

shindomo_3-1632315371095.png

 

Thank you.

VJR
Super User
Super User

Hello @mbeser 

 

As per your note if you want to do it without manual operations then you can

- Write an Excel macro that changes the font of Word documents (tons of readymade code easily available on the web)

- And then call that macro from within PAD.

VJR_0-1632479061289.png






-------------------------------------------
Help fellow beings find relevant posts.
Upvote to a supporting response.
Mark as solution to an answer.

@mbeser 

PS: I can help you with the macro in case you need.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (6,008)