![]() ![]() Now we could cheat and access the full file name and path by accessing the FullName from the drive system. ![]() $Files=GET-CHLDITEM ‘C:\FooFolder\*.DOCX’ Let’s pretend we ran the following lines in Windows PowerShell: But what if we have a folder of DOCX files that we want to convert at once? All we need to do is run a Replace() method on the provided file name, and swap. Let’s just take a known file name and resave it as a PDF file with the same file name. With these three bits of information, I don’t have to actually know the file name. So I could do something like this: Open some file, get the file name information, swap out. ![]() $Doc | get-member –membertype property *Path* In poking about and using a similar search for Path, I found the property holding its path. $Doc | get-member –membertype property *Name* I poked out using the following cmdlet to…well, to be honest…to guess. Three of the available properties in the Word object are the Name of the document, the Path to the document, and the FullName path. We can access the file name of that single document in the following way. What if I want Microsoft Word to save that PDF file with the same name as the parent without knowing the name? If your brain didn’t pop out just now, you’re OK. pdf format, things get a wee bit fancier. If we would like to save it in an alternate format, like in. $Doc=$(“C:\Foofile.docx”)Īnd along the same lines, we could save this same file in the following manner. $Word=NEW-OBJECT –COMOBJECT WORD.APPLICATION So accessing a file in Microsoft Word programmatically is quite easy. I’m about to leap out of my chair because I hear “Bulk.” Many to do, repeatable, and… The wires and lights starting blinking in my head. ![]() Oh, if ONLY there was some way to do this in bulk.” But I want to do multiple documents at the same time. My boss looks up at me today, and sighs, “I love the built-in SaveAs PDF in Word 2013. Today’s blog is brought to you by Windows PowerShell MVP and honorary Scripting Guy, Sean Kearney. Microsoft Scripting Guy, Ed Wilson, is here. Summary: Windows PowerShell MVP, Sean Kearney, talks about using Windows PowerShell to convert Word documents to PDF files en-masse. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |