Scripting Blog

A place to learn about PowerShell and share stories of automation

How Can I Replace Text in a Microsoft Word Document?

Hey, Scripting Guy! How can I search a Microsoft Word document for all occurrences of the string <computername> and replace those occurrences with the actual name of a computer (e.g., atl-ws-01)?-- WC Hey, WC. And by the way, thanks for your question. Microsoft employees will be getting their yearly performance reviews back sometime ...

How Can I Search For (and Reformat) Highlighted Text in a Word Document?

Hey, Scripting Guy! How can I find text in a Word document that has been highlighted in a particular color (say, turquoise), and then both remove the highlight and change the font color of that text to something else (say, blue)? I’d be extremely chuffed if you can solve this one!-- KB Hey, KB! Blimey! You know, when we first saw your ...

How Can I Get a List of the Unique Words Used in a Microsoft Word Document?

Hey, Scripting Guy! How can I get a list of the unique words used in a Microsoft Word document?-- RK Hey, RK. Funny you should mention unique words. Last Saturday the Scripting Coach’s baseball team played in the city championship. Despite the importance of the game the team was missing two key players, and the Scripting Coach knew that ...

How Can I Add Multiple Tables to a Word Document?

Hey, Scripting Guy! How can I add multiple tables to a Word document?-- KH Hey, KH. You know, if the Scripting Guys have one failing (hey, we said if) it’s this: we’re simple guys with simple tastes. Create a Microsoft Word document with multiple tables? No, sir; that’s not for us, not at all. One table per document is plenty, thank ...

How Can I Close a Command Window with a Specific Title?

Hey, Scripting Guy! How can I use WSH to close a command window with a specific title?-- MF Hey, MF. You know, some things are just really hard to believe, regardless of whether or not they happen to be true. For example, according to the Big Bang Theory the entire universe was created when a miniscule spec of super-dense matter exploded ...