MS Office Forum / Word / Programming / April 2005
Saving .dot files
|
|
Thread rating:  |
Dawn Rhoads - 08 Dec 2004 00:29 GMT Any brilliant person out there who can make a "save as .dot" macro, that will automatically retain the original file name and file location, and save it as a .dot file? Bacground of why I would need such a thing is below. Thanks in advance for any help or thoughts anyone can offer!
We use a lot of templates in Word. We are on Word 2003. Starting when we moved to Word XP, I have encountered a problem where my .dot files do not want to save correctly. In Word 97, if I opened my .dot file, it would open as .dot, I could work on it, and it would save as .dot. No problem. Now, for some reason, Word wants to save it as a .doc. Sometimes it warns me it is doing this, sometimes not. :( Even better, sometimes it *appears* to be a .dot, but it behaves like a .doc. Of course, several features of a template don't work correctly if it's not saved in the correct .dot format (for instance, the "createdate" field).
I tried changing my default file format to be .dot, but that was a pain because then all my regular documents want to default to be saved in my personal templates folder. I tried changing my templates location so it at least pointed to the highest level of our shared templates, but that made it so my personal autotext and personal toobars didn't work (since my Normal.dot is saved in my templates directory. I can't save my Normal in the shared drive, I don't think, since that would probably over-ride everyone's personal Normal? I was afraid to try that.)
The only way around this seems to be to always do a "save as" and specifically choose the .dot extension. Unfortunately, this automatically takes me to my personal templates folder (instead of the shared templates folder it originated from) so I have to re-navigate back to the correct folder (we have multiple folders for our shared templates, so they are split out onto separate tab in the Templates window) and then save. This is a pain. It's far more than a pain when Word sneakily makes a .dot file into a .doc and loses autotext and macros built into that file. (Yes, it should warn me, but it doesn't always do so. Really, I swear. I know you don't beleive me, but it's true. I have reported it to MS on their website, but to date have not seen anything in the Knowledgebase addressing it.)
I'm sure this is some problem with our MS Word, but no one in my company's Tech Support wamts spend any time on the phone with Microsoft for this, since I'm the only one here who works on our templates. So, after struggling with this for a year or so, thinking maybe I would get used to it, or maybe I was crazy and it would finally stop doing it, I'm looking for other options.
Any thoughts would be greatly appreciated!
Peter - 08 Dec 2004 00:35 GMT Instead of double-clicking on your templates when you want to edit them, right-click and choose "Open" instead of "New".
hth,
-Peter
> Any brilliant person out there who can make a "save as .dot" macro, that will > automatically retain the original file name and file location, and save it as [quoted text clipped - 39 lines] > > Any thoughts would be greatly appreciated! Charles Kenyon - 08 Dec 2004 20:26 GMT The way to use templates is not to _open_ them but to create a new document based on the template. You open the template only when you want to make changes that will be reflected in all future documents created from the template. The only time you would open a template and use Save As with it is when you want to create a new (different) template. For more on the different kinds of templates, tabs on the file new dialog, and locations of templates folders see http://addbalance.com/usersguide/templates.htm.
As for sharing, see http://addbalance.com/word/movetotemplate.htm for step-by-step instructions on moving / sharing / copying / backing-up customizations including AutoText, AutoCorrect, keyboard assignments, toolbars, macros, etc.
 Signature Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://www.mvps.org/word which is awesome! --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom.
> Any brilliant person out there who can make a "save as .dot" macro, that > will [quoted text clipped - 55 lines] > > Any thoughts would be greatly appreciated! Dawn Rhoads - 09 Dec 2004 21:41 GMT Thanks for the replies, Charles and Peter, but we don't seem to be on the same page regarding my problem.
1) I am trying to make changes to my underlying template, so I need to open the template itself, not create a new document based on it.
2) I really am opening the template itself -- in Word I go to File/Open and navigate to the folder where the templates are saved and open the template itself. I know it is the template and not a "new" document, because the title bar across the top shows the correct file name (such as "Basic Letter.dot") not "Document1" as it would for a new document.
So... I'm pretty sure I'm opening things like I should. As I said, in years past I never had this problem. I haven't changed how I'm working on these Templates, Word has changed how it's reacting. For whatever reason, Word is behaving strangely with respect to saving the files. I must be the only person who is having this problem, which I agree is completely weird, but that's what's happening.
Given all that, I'm hoping someone could devise a "save as..." macro that I would 1) retain the name the file already has (Word is already doing this correctly) 2) make sure the file type is .dot (this is where Word screws up for me) 3) keep the file in the location it started in (when I choose a file type of .dot Word automatically flips to my personal templates directory, so I have to re-navigate back to the original location)
If anyone could do something like this, it would be a big help to me. I can record a macro, but don't have enough skill to write one, especially one that includes variables like this one would have to. Thanks for any time or attention anyone could offer on this!
> The way to use templates is not to _open_ them but to create a new document > based on the template. You open the template only when you want to make [quoted text clipped - 68 lines] > > > > Any thoughts would be greatly appreciated! Peter - 09 Dec 2004 22:36 GMT OK, sounds like you are following the correct procedure for opening a template for editing. I think you're expecting it to behave correctly, and I can't tell you why it's not behaving as you'd expect it to behave. It sounds like there is some flag in Tools -> Options that is toggled the wrong way, or some other setting that needs to be changed; perhaps someone else knows if this behavior is controlled by an option?
Seems like the real fix is to change the behavior of Word, probably by toggling a setting/flag, but if you can't get there, the following macro should give you a workaround:
Public Sub FileSave() ' test for a template two ways, in case Word is changing the document type when it opens. ' testing the type is the "right" way to do it, but checking the extension will work, too If ActiveDocument.Type = wdTypeTemplate Or Right(ActiveDocument.Name, 4) = ".dot" Then ' this document is a template ' save the document to its current location as a template Call ActiveDocument.SaveAs(ActiveDocument.FullName, wdFormatTemplate) Else ' this document is not a template, so simply save it. Call ActiveDocument.Save End If End Sub
To install the macro, open Normal.dot just like you'd open any other template (make sure no other Word documents are open at the time), press Alt+F11 to open the VBA IDE, double-click "ThisDocument" in the Project Explorer (Ctrl+R if you don't see it), and paste the macro in. then save Normal.dot (it should save correctly with the macro in place). Now every document you open will run this macro whenever you click File->Save or hit Ctrl+S. One caveat to this is that if the document is a new one, then ActiveDocument.Save will open the Save As dialog box. If the user then clicks Cancel, an error box will pop up displaying "Command failed". I remember reading about a way around this, but I couldn't find it. Perhaps someone else remembers. It's not to use "On Error Resume Next" because that causes the Save button in the Save As dialog to not function.
hth,
-Peter
> Thanks for the replies, Charles and Peter, but we don't seem to be on the > same page regarding my problem. [quoted text clipped - 100 lines] > > > > > > Any thoughts would be greatly appreciated! Dawn Rhoads - 09 Dec 2004 23:13 GMT Thanks Peter I will try this!
I totally agree, it really seems like some setting or other must be goofed up, but I've tried several different attempts to locate some such thing without success.
One question, do you think there would be a way to change it so it doesn't intercept the main "save"/control-S function? I think it would work just as well for me if it was it's own special command and/or button (I would be able to do this part on my own, you don't need to work explain that part for me) that I could use specifically when I'm working on a template. Then it would avoid the issue you pointed out for new documents.
I work on my templates as a very specfic part of my job and I'm always aware when I'm working on a template vs. a regular document so that shouldn't be a problem for me.
Thanks again for your help and time on this!
> OK, sounds like you are following the correct procedure for opening a template for editing. > I think you're expecting it to behave correctly, and I can't tell you why it's not behaving as you'd expect it to behave. [quoted text clipped - 126 lines] > > > > > > > > Any thoughts would be greatly appreciated! Peter - 10 Dec 2004 01:37 GMT > Thanks Peter I will try this! > [quoted text clipped - 4 lines] > One question, do you think there would be a way to change it so it doesn't > intercept the main "save"/control-S function? Oh, yeah, easily. Change the name of the Sub to something else. "SaveDot" would work fine. Then add a button that invokes it. Or add a keybinding. Or both.
hth,
-Peter
Dawn Rhoads - 18 Apr 2005 20:43 GMT This is an old thread, but just for the benefit of anyone following it, or looking it up later, the macro is working for us (hooray!) I stripped it down to just one element, however --
Call ActiveDocument.SaveAs(ActiveDocument.FullName, wdFormatTemplate
because I want all the files I will use this with to be saved as Templates, regardless of what format they started out as.
One thing we noticed here is that since we lock (aka "protect") our templates before saving them, seems like the only way this macro will run is to assign it to a toolbar button. You won't be allowed to pick it from the macro list, and it was reported to me that using a keyboard shortcut didn't work either (although I did not test that myself).
Thanks for your help, Peter -- this is going to save me a tremendous amount of time in an upcoming project involving mass changes to all our templates -- cutting out those two or three extra clicks will make a big difference both in time and in my mental attitude! :)
> > Thanks Peter I will try this! > > [quoted text clipped - 10 lines] > > -Peter
|
|
|