((_Document)doc). Object saveChanges = WdSaveOptions.wdDoNotSaveChanges doc has to be cast to type _Document so that it will find the
Close the Word document, but leave the Word application open. Ref oMissing, ref oMissing, ref oMissing, ref oMissing, Ref fileFormat, ref oMissing, ref oMissing, Object fileFormat = WdSaveFormat.wdFormatPDF Object outputFileName = (".doc", ".pdf") Ref oMissing, ref oMissing, ref oMissing, ref oMissing) Ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, Use the dummy value as a placeholder for optional argumentsĭocument doc = (ref filename, ref oMissing, Object filename = (Object)wordFile.FullName Get list of Word files in specified directoryĭirectoryInfo dirInfo = new wordFiles = dirInfo.GetFiles("*.doc") C# doesn't have optional arguments so we'll need a dummy value Create a new Microsoft Word application object Note that you'll need to add a reference to to the solution. doc files, opens them in Word and then saves them as a PDF.
It uses Word 2007 with the Save As PDF add-in installed. Here is a modification of a program that worked for me. Var pngTarget = Path.ChangeExtension(target, "png") Using (var ms = new MemoryStream((byte)(bits))) Var target = path1 +j.ToString()+ "_image.doc" int j = 0 įoreach (.Page p in pane.Pages)
Word 2016 for Windows lets you easily convert your documents into more than a dozen different formats, using the process detailed here.Use a foreach loop instead of a for loop - it solved my problem. Choose the format you want and click Save.Open the drop-down menu next to Save as type to see a few additional options, such as Word XML Document, Strict Open XML document, and Web Page, Filtered.
How to save a Microsoft Word doc in different file formats If the file format you want isn't available in Microsoft's default option, you can also dig a bit deeper for additional file format options. If you want to continue using the same app to open PDFs in the future, check the Always use this app to open.By default, Windows will use the Edge browser but you can choose from other compatible browser apps installed on your PC, as well. You may see a How do you want to open this file? pop-up box.A new box labeled Publish as PDF or XPS appears, and you should use it to navigate to the location on your PC where you want to save the new PDF.Ĭlick Publish to create and save your PDF.(It looks like a document icon wearing a seatbelt.) With the Create XPS/PDF Document option selected, click the corresponding box on the right side of your screen. See on Microsoft Store How to save a Microsoft Word doc as a PDFĬlick the File tab in the top-left corner of your Word screen.Ĭlick Export in the blue vertical menu that runs along the left side of your screen. Microsoft Word 2016 for Windows has a basic feature that lets you save documents in several different, but common, file formats. But what if someone else requests a file in a different format, such as PDF? What if you need the info in your Word doc to appear in plain text, without any font or paragraph styles? It's simple and easy-to-use, and it simply gets the job done in most cases. You use Microsoft Word for your various word-processing needs.