How can I programmatically save a document

M

Micheline

How can I programmatically save a document once I have detached it from the
original template it was created?

The code does work only if… the Original template is open at the time, then
the detached document gets saved programmatically.

The reason why I need this functionality is because I don’t want the macros
on the customized toolbar to be available once the document is completed)

For now, if I detach the template, the document needs to be saved (i.e. the
user gets prompted to save), the ActiveDocument.Save does not get executed.

See code:

ActiveDocument.AttachedTemplate = ""
ActiveDocument.Save

Hope someone can help me and thanks very much.
 
J

Jezebel

1. Every document has an attached template. The only thing you can change is
which one. This instruction

ActiveDocument.AttachedTemplate = ""

has the same effect as

ActiveDocument.AttachedTemplate = "normal.dot"


2. The Save instruction has no effect if the document is already saved,
meaning .Saved = true. You can test what's going on in the immediate
window --

[do instruction]
? ActiveDocument.Saved

.... if the answer is 'true' then your instruction had no effect. You can
force the issue by setting .Saved = FALSE

However, ...
If your save instruction is not working following your .AttachedTemplate =
"", that suggests that the document is already attached to normal.dot. In
which case you can't detach it (unless you attach it something else); but if
your code and toolbar are part of normal.dot, you're going to get them
anyway.
 

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