Printdocument file path




















See what works and what doesn't. When you open a Word document, Word displays its name in the title bar. If it's a new blank document, Word displays a generic name, document x , until you name the file. That's adequate for most of us, but occasionally, you'll want the document's name to print with the content or you'll want the entire path in the title bar.

Unfortunately, both requirements often leave users scratching their heads in frustration. That's because what seems simple has some unexpected kinks. In this article, I'll show you solutions to these requirements and warn you when they don't work as expected. I'm using Word on a Windows 10 bit system, but you can apply these solutions all the way back to Word You can use any file you want or you can download the demonstration.

The solutions discussed in this article aren't compatible with When you want to display the document's name and path in the file itself, you can type it, but if you change the filename, you must remember to update the name in your document.

You must remember to update the field--how is that any better than typing it manually? One advantage is clear when you're working with multiple instances of a filename: Updating the field once updates it throughout the document. As you can see in Figure C , Word displays the name and path in the document's header, so it'll be visible on every page of the document. Later, I'll show you how to display it conditionally. Unfortunately, if you save the file using a different name, you must update the field manually to display the new name.

To do so, open the header, right-click the field, and choose Update Field Figure D. If you're using our demo file, be sure to open the header and update the field to see the correct path for your system. If you're likely to forget to update the field and it's important that the file print with the right name, you can set a print option to update fields before printing, as follows:.

Without a lot of effort, this is the best you can hope for. You might consider adding an ActiveDocument. Update event to the FileSaveAs event, but the timing's wrong and it won't work. VBA updates the fields before saving the new name. The file won't update the field the next time you open it either, so you might consider adding the Update event to an AutoOpen macro, so at the very least, the document displays the correct name when opened. However, doing so won't help if the field is in the header or footer.

The update method updates fields only in the document body. Frequently Used Methods. Show Hide. Print Dispose ThrowIfNull 1. ToString 1. Related in langs. NewUnderlyingProduct Go. NewStats Go. FileTransferManager Java. ControlProcess Java. SrRealParSet Python. Connection Python. Example 1. Show file. File: CPrintMethods. Example 2. File: PrintThreePages. Draft prndoc. Example 3. File: PrintDocumentMethod. Open, FileAccess. DrawImage img, ev. Example 4. File: orderlist.

Example 5. File: Printing. Example 6. File: printService. Example 7. File: UserControlChecks. He can then specify in this dialog box the name of the pdf file and where to store it. As the amount of files is large and it is annoying and error-prone to find always the correct path and name, I would like to set already the correct path and filename in this dialog box programmatically.

I already tested these attributes: PrintDocument. PrintFileName PrintDocument. DocumentName Writing the required path and filename to these attributes didn't help. My environment: Windows 10 Visual Studio Monday, November 30, AM. Best regards, Kristin We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time.

Tuesday, December 1, AM. Hi Have you got the solution for the problem. Friday, November 17, AM.



0コメント

  • 1000 / 1000