Save w/o attached template macros

D

David Turner

At one time under Word2000, I had created a file with an attached template
which ran a userform creating a new calendar and then saving itself as a
new .DOC file WITHOUT the attached macros/template. Then for a period of
time I included all that code in a .DOC file and used the 'save as RTF'
method from within that code instead, but now I want to go back to .DOC +
attached template.

For the life of me I can't duplicate the steps I took to have the file
created by the macro saved as .DOC format without retaining all the
template's code, which of course fires when I reopen the newly created .DOC
file.

Can anyone provide the necessary steps for me?
 
D

David Turner

David Turner wrote
At one time under Word2000, I had created a file with an attached
template which ran a userform creating a new calendar and then saving
itself as a new .DOC file WITHOUT the attached macros/template. Then
for a period of time I included all that code in a .DOC file and used
the 'save as RTF' method from within that code instead, but now I want
to go back to .DOC + attached template.

For the life of me I can't duplicate the steps I took to have the file
created by the macro saved as .DOC format without retaining all the
template's code, which of course fires when I reopen the newly created
.DOC file.

Can anyone provide the necessary steps for me?

Well, after reloading older versions of the 'working' files, I discovered
I had assigned a button to generate the form. Preferring the form on
opening the file, I fumbled around after a Google search and added this
after the routine's Save As line:

ActiveDocument.AttachedTemplate = ""
ActiveDocument.Save

Works!
 
D

Doug Robbins - Word MVP

Hi David,

If you select File>New and then select the template as the basis of the
document that you want to create, the macros in the template will not be
saved with the document.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
D

David Turner

Doug Robbins - Word MVP wrote
If you select File>New and then select the template as the basis of the
document that you want to create, the macros in the template will not be
saved with the document.

Thanks. Got it sorted as reported in followup to myself. A static "work"
document is already in place and macros within the template act on that
document to create a third file. The key element I had forgotten was that
I previously had a custom toolbar button on the standard toolbar of that
"work" document that actually launched the UserForm and subsequent macros
in the template. When I tried to launch the UserForm via Private Sub
Document_Open() in the template itself, that's where I ran into the
problem of it being saved with the "finished product", circumvented for a
few months with all code in the "work" document by saving in RTF format.

Critical code as it works now with *all* code in template simply attached
to the "work" document:

' input retrieved from UserForm
' actions taken to create finished product
' then --
ActiveDocument.SaveAs FileName:=Left(UCase(ActiveDocument.Words(1)), 3) &
Right(ActiveDocument.Words(3), 2) & "MNU.DOC" 'saves finished product
ActiveDocument.AttachedTemplate = "" 'strips the template
ActiveDocument.Save 'saves the finished product
End Sub

May not be according to Hoyle, but it works as desired.
 

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