Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    239
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Save As Name (Word 2000 SR1a)

    I have a global template that contains the VBA used by documents based on Std Report.dot.
    When a document is created, a number of docvariables are created and used to feed information to the cover page and the headers and footers. One of these variables is called "Title".
    What I want to do is create a macro that brings up the Save As dialog box with "Title" as the default document name.
    Is that possible please? I have identified the line ActiveDocument.SaveAs but I cannot figure how to use the variable and I am not sure if that would save the document without the user seeing the Save As dialog box, thus enabling them to navigate to the required directory.
    Any help appreciated.

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default Save As Name (Word 2000 SR1a)

    Hi Peter:
    I'm not much of an expert on VBA, but I do know that the default SaveAs name for a custom template is whatever is put in the Title box of the templates properties dialog box. Does that help any?

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Default Save As Name (Word 2000 SR1a)

    See <!post=Post #126305,126305>Post #126305<!/post>.

  4. #4
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    239
    Thanks
    4
    Thanked 1 Time in 1 Post

    Re: Default Save As Name (Word 2000 SR1a)

    Phil
    Your idea would have worked if I had left that field blank and the file name was to be the same as the first line of the document. Thanks for the idea though.

    Jefferson
    That was the bit of code I needed. Works perfectly, Many thanks.

  5. #5
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Default Save As Name (Word 2000 SR1a)

    Is this really a global template? What you are doing sounds like something that would normally go into a document template since it isn't likely to be used by most documents and wouldn't need to be in memory all of the time. Also your layout, etc. would normally be in the document template rather than a global.

    Why not use document properties rather than document variables? If you use the "Title" document property, it will be the default document name.

    Also, if you have DOCVARIABLE fields in your headers or footers and someone tries to open it in Word 97 it may crash Word.
    Charles Kyle Kenyon
    Madison, Wisconsin

  6. #6
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    239
    Thanks
    4
    Thanked 1 Time in 1 Post

    Re: Default Save As Name (Word 2000 SR1a)

    Charles
    The way I have set things up is this
    Master.dot
    Contains all the VBA including a dialog box that appears when a document is created. It is held in Word's startup path.
    StdReport.dot
    Is what the user works from.
    The only VBA in stdreport.dot is a line to call a dialog box when the document is created. (Changes are via the same box called via another macro in master.dot.)
    When the user clicks OK, the line in master.dot
    .Variables("Title") = frmReport.txtTitle.Text
    takes the input and shows the title on the cover page and in the headers and footers.
    Your response raises two issues.
    DOC PROPERTIES
    I thought that using doc properties would bring up either whatever text was in Title in the template OR the first line of the document if that property was blank in the template. Is that not the case? Is there a way of using my variable? The idea is to get the document saved with the title name without the user having to type it again.
    WORD 97
    This concerns me as some users will have Word 97. The headers and footers also get their information from the dialog box input. Is there an approach that allows me to give the user a single point of input for all this information? I suppose one option would be a table at the front or back of the report and set up the input as bookmarks and then cross reference them on the cover and in the headers and footers. Does not look good to the reader though and also encounters Word's long outstanding bug when changing bookmark content (delete the last word last). Can you suggest anything please?

    Thank you for your input and particularly for pointing out the problems with Word 97

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Default Save As Name (Word 2000 SR1a)

    Peter,

    One way to do this would be to assign the value which the user types into the userform, to a custom document property. You could then use DocProperty fields which refer to this custom document property, in the various places in the document where this info needed to be written to. (You would also need to have some code that would update fields in all story ranges for the document.)

    Gary

  8. #8
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    239
    Thanks
    4
    Thanked 1 Time in 1 Post

    Re: Default Save As Name (Word 2000 SR1a)

    Hmm!
    I managed to work my way through doing it all with variables by referring to my text book. Custom doc properties are something I haven't used and at the moment I don't have a clue. Guess it's time to dust off the text book, hope there aren't too many differences using this method!
    Many thanks.

  9. #9
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Default Save As Name (Word 2000 SR1a)

    Your userform can assign values to document properties as easily as it does to document variables. Take a look at How to use a single VBA procedure to read or write both custom and built-in Document Properties. You may also want to check How can I get access to the Document Properties of a Word file without opening the document? for another feature of document properties you may find useful.

    The big difference between Document Properties and Document Variables (other than not crashing Word 97) is that properties are available to a user without using VBA and available to a user from outside the document (even from Windows).

    You can also get information into headers if it is anywhere in the body of your document by skillful use of the StyleRef field.

    Finally, yes, Word will usually pick up the first line in the document body for its default document name if the Title property is empty.

    It sounds like a masterful application you are building. I hope your users are at least a little appreciative, but won't hold my breath.
    Charles Kyle Kenyon
    Madison, Wisconsin

  10. #10
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    UK
    Posts
    239
    Thanks
    4
    Thanked 1 Time in 1 Post

    Re: Default Save As Name (Word 2000 SR1a)

    Charles
    Thank you for this additional information. I will be following up the links you have so helpfully provided.
    There's quite a bit more to what I have built than these postings cover.
    - Single click to switch from portrait to landscape and back
    - Single click for a variety of preformatted tables
    - All the styles accessible from the toolbar
    - Cover page and all headers and footers created from the dialog box accessed on creation or subsequently recalling the dialog box
    - Custom Save As which defaults the Title into Save As
    - A variety of bullet and numbered styles, all vertically aligned by default but stepping neatly under each other using the indent tool.
    I don't suppose everyone will appreciate the effort but the feedback from the pilot users has been very positive.
    I have produced a generic version (i.e. all company identity removed) with a guide. If you would like to take a look, I would be quite happy to send it to you. Just let me have an address (I won't use it for any other purpose).
    Peter

Posting Permissions

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