You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Microsoft Word and Automator

I'm trying to Find/Replace text in a stack of Word.docx files (and I have to do this a lot). Automator should do this as it offers the ability in the 'Library'. However, it fails to open the documents.


Comes up with the following:


The action “Open Word Documents” encountered an error: “Can’t get item 1 of missing value.”


The commands I'm using are:


'Get Specified Finder Items'

'Get Folder Contents'

'Open Word Documents' This is where the system falls down :(

'Find and Replace Text in Word Documents'

'Save Word Documents'

'Close Word Documents'


There are no options for 'Pages' in the Library. Automator is working fine with Excel.


Automator is V 2.10

OSX is Catalina 10.15.4

Word is V 16.35 (Office 365)


If I can get this working it will save me a TRUCKLOAD of time and energy.


Any suggestions?



iMac 21.5", 10.15

Posted on Apr 13, 2020 8:12 AM

Reply
Question marked as Top-ranking reply

Posted on Apr 13, 2020 11:14 AM

Are any Word documents returned when you get the folder contents? It looks like there is at least one (Copy Doc).

The "missing value" means that the Open action got passed an empty object. I can't tell you why.


I don't have those actions, but I would assume you do not need to open them in order to run the find and replace action.

Also note that everything is passed down the workflow chain, so the original folder from Get Specified Finder Items is being passed into Open Word Documents and the Find/Replace action, along with the contents of that folder.


What do the Open Word Documents and Find and Replace actions expect as input? Select them in the Library list and it will tell you what they want passed. If it is purely Word Documents and not files and folders, then you would need to filter for Word documents before those actions.

Similar questions

8 replies
Question marked as Top-ranking reply

Apr 13, 2020 11:14 AM in response to Ennarar

Are any Word documents returned when you get the folder contents? It looks like there is at least one (Copy Doc).

The "missing value" means that the Open action got passed an empty object. I can't tell you why.


I don't have those actions, but I would assume you do not need to open them in order to run the find and replace action.

Also note that everything is passed down the workflow chain, so the original folder from Get Specified Finder Items is being passed into Open Word Documents and the Find/Replace action, along with the contents of that folder.


What do the Open Word Documents and Find and Replace actions expect as input? Select them in the Library list and it will tell you what they want passed. If it is purely Word Documents and not files and folders, then you would need to filter for Word documents before those actions.

Apr 17, 2020 5:18 AM in response to Barney-15E

Thanks, Barney-15E,


No docs are returned. The docs you can see are the results from the 'Get Folder Contents' action.


The word docs need to be opened by the 'Open Word Documents' action, otherwise there's a break in the workflow (top & middle arrows), which pauses the workflow indefinitely (bottom arrow).



I guess that the 'Open Word Documents' and 'Find and Replace' actions are looking for Word docs. I can't see any filter actions though.



Word updated to V 16.36, but still no dice with Automator.


Any ideas??

Apr 17, 2020 6:02 AM in response to Barney-15E

Hi, Barney-15E,


Thanks for your patience and assistance.


I've tried again with a folder that ONLY has word docs in it. Same thing happens:


Word then opens up a blank doc with this dialogue box:



Looking at 'Find & Replace' (though the workflow doesn't get this far), it's looking for the following:


Looking at the copyright, it says 2010 - is it possible that this is just not supported any longer? If so, why is it in Automator?


I'm stumped, but am willing to try anything.

Apr 20, 2020 8:32 AM in response to VikingOSX

Thanks, VikingOSX,


I'm very new to Scripting so please bear with me.


I've managed to get Automator to open documents using the "Open Finder Items" application. Having scoured around the internet, I've got the following AppleScript that will work with the first document only:



So I can automatically find and replace on one document. Not great but progress, I suppose.


Any ideas how I can script my way to getting this to work on all the open Word docs?


Or, is there an App that can do this?


I know MS stopped supporting Automator after 2011, but this seems like such a time saver, I can't believe the solution isn't readily available.

Apr 17, 2020 5:46 AM in response to Ennarar

Your Open Word Documents is receiving a lot of stuff that is not a Word document. That may be the problem.

As you can see, Open Word Documents expects "Files of type .docx, .doc, .txt, .rtf, .html." It may not be smart enough to verify what they are before attempting to open them. Or, it may be the folders that are returning empty items to the Action.


What does Find and Replace expect to receive?

I don't have these Actions, so I can't look them up myself.

Apr 17, 2020 6:48 AM in response to Barney-15E

No idea where they came from - just on there when I opened Automator up.


With regard to not working at all, I think you're probably right.


Interestingly, I don't have any actions for Pages/Numbers in there, which is...odd.


Oh well, back to the drawing board (or learning Applescript) I guess.


Thanks so much for time, though Barney-15E. You're a star.


Have a great weekend.

Apr 17, 2020 8:15 AM in response to Ennarar

Instead of the Open Word documents action, you could use a Run AppleScript action to pluck the individual Word documents fed into it from the previous action, open each one in a loop, and scrutinize the Word AppleScript dictionary to determine support for find/replace, and other document properties. Launch Script Editor, and File menu : Open Dictionary… : Word.


on run {input, parameters}

tell application "Word"
   -- process each Word document passed into this action
   repeat with anItem in input
   -- set docx to open anItem
   -- any relevant find/replace supported commands from Word scripting dictionary
   -- close docx
   end repeat
end tell
return

end run

Microsoft Word and Automator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.