Results 1 to 2 of 2

Thread: How to change word file name before saving?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    177

    How to change word file name before saving?

    Hello

    My VB6 application creates report into MS Word documents. When I create new blank document the names look like Document1, Document2 ....
    But what I need to achieve is change this name based on my entered text before saving!

    I've tried to change through the property doc.Name but it's read only.

    the code bellow also doesn't solve my problem:
    Code:
    doc.BuiltInDocumentProperties(wdPropertyTitle) = DocumentName
    doc.ActiveWindow.Caption = DocumentName
    This changed name is important for me as I use it as automated text in document footer and it is still only "Document1".

    In summary, I want to create Word document, change name from "Document1" to my value, generate footer with my value DocumentName but everything without saving!!!

    Can somebody help me?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to change word file name before saving?

    you can not change the name of a document while it is open

    you can change the caption displayed
    you can change the title, which may later be used as a suggested file name if using saveAs

    you can put a field in your footer, it will then have the correct document name after it has been saved

    if you are never going to save the document you can put your own string in the footer as filename
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width