FileSave in Global dot

M

Michael Tissington

Is it possible to trap the dialogs FileSave and FileSaveAs in a global dot ?

Thanks.
 
M

Mark Tangard

Not directly, because the built-in FileSave and FileSaveAs
commands will be found first. But what you could do is write
2 macros with those names, stored in *Normal.dot*, have their
code call the version in the global, e.g.,

Sub FileSave
Call MyGlobalProjectName.ModuleName.MyAardvarkFileSave
End Sub

Obviously though, this won't work for a global that you plan
to distribute since you don't have control over the user's
Normal.dot.

What is it you're trying to achieve? Maybe there's a simpler
way.
 
M

Michael Tissington

I have an application that enables the user to choose a base template to
design their own template from.

I'm doing something like Documents.Add(template_name, True)

When the user clicks Save, or SaveAs word defaults to the default Templates
folder.

I need it default to the location of the original template, template_name.

Any ideas please?
 
M

Mark Tangard

Hm. I don't see a way out there; new-template-saving has always
been rather fiercely tied to the User Templates folder. A very
convoluted approach that occurs to me is, if you had access to
the user's Normal (or using the odd route I suggested earlier),
have your custom FileSaveAs command *switch* the User Templates
folder (Options.DefaultFilePath(wdUserTemplatesPath)) to the
path of the attached template, then do the save, then revert
the User Templates folder. But it seems like something in that
mess would fail to cooperate.

Could you give each of your templates a custom toolbar button
to be used only for saving the user's newly created template?
It wouldn't be as transparent (i.e., the user wouldn't run the
built-in Save), but you could code the path into the button.

BTW, however you end up doing this, you won't need to mess with
both FileSave and FileSaveAs -- only FileSaveAs. (When a user
invokes 'Save' on a file that hasn't yet been saved once, Word
actually runs Save As, not Save.)

--
Mark Tangard, Microsoft Word MVP
Please reply only to the newsgroup, not by private email.
Note well: MVPs do not work for Microsoft.
"Life is nothing if you're not obsessed." --John Waters
 
J

JGM

Hi Mark and Michael

Just a thought I just had...
I maybe wrong, but just in case, here goes:
I do not think you want to mess around with SaveAs in a case like this
because when the user creates a document based on template B (which, let's
say, was created from Michael's template A), won't Michael's SaveAs routine
be called everytime the user wants to save that document for the first time
(a *.doc basd on the template created from the original template), or
whenever the user actually wants to do a Save As...?

I concur with Mark that it would be fairly easy to get the UserTemplatePath
from your template and assign that to the SaveAs when the user creates his
own template.

I did something like this a while back (Create a template for users to
create their own templates from). I used a button on a custom toolbar that
would disappear (the button, not the toolbar because I had other stuff on
the toolbar that the second template would need) once the second template
had been saved. It worked very well. The way I did it though was to get the
user to *open* my template (Not create a doc from my template, and then a
*.dot from the *.doc from the original template (because I wanted a custom
toolbar and associated modules to be part of the newly created template) and
to do a SaveAs from there. I had all kinds of message warnings to make sure
the user would not mock around with the original...

HTH
Cheers.
 
M

Mark Tangard

Jean-Guy,

I'm not where I can test it, but I'd say you're probably right.
And it seems like it'd be equally hard to get around that --
running yet another macro for a *true* FileSaveAs and placing
it on the File menu. Bleah!

Your ephemeral-button idea sounds interesting, but of course,
it's always risky to let users open templates directly.

Maybe a different approach would work: Say, a AutoText, or
a set of them, that could be assembled into an unsaved file,
and a custom button that saves that file as a template in
the appropriate folder (only if ActiveDocument.Path = ""
that is, only if it hasn't yet been saved, otherwise it'd
call the FileSave command).

But that seems too easy, I must be forgetting something...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top