Re: Preventing macro from copying over from template to document
- From: "Jonathan West" <jwest@xxxxxxxx>
- Date: Thu, 26 Jun 2008 16:26:43 +0100
"chris_huh" <chris.huh@xxxxxxxxx> wrote in message
news:57e4b90e-bf01-4ff4-8b9b-156b44e9d778@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 26 Jun, 14:00, "Jonathan West" <jw...@xxxxxxxx> wrote:
<<Ah yes i see. In the projects box (top left) it lists the template and
the document. The ThisDocument thing under the document is blank. I
think you can see what i'm going to ask next. Is there a way to remove
this template reference so when you open that document there is no
Enable Macros request?>>
Yes. Add the following line to your macro at some suitable point.
ActiveDocument.AttachedTemplate = NormalTemplate
Then the document will be attached to Normal.dot, not to the template.
Alternatively, digitally sign your template so that it is regarded as
being
trusted, and the warning will no longer appear. If it is just for local
use,
you can create your own certificate. On the Windows Start menu, go to
Microsoft Office, then Microsoft Office Tools. In that submenu you should
see "Digital Certificate for VBA Projects". Click that and follow the
instructions.
<<I also changed that code for the saving. That now allows you to change
the location and name (great, thanks) but is there a way for that to
happen when you click Save, rather than close. I guess you woudl take
that bit out of the Document_Close sub, but what would i put it in?>>
Create a new module, and create a routine in it called FileSave Put the
code
I provided into that routine.
--
Regards
Jonathan West - Word MVPwww.intelligentdocuments.co.uk
Please reply to the newsgroup
Thats got rid of the Enable Macros dialog, thanks.
I am not too proficient with macros and vba. Is a routine different to
a sub, etc. How would i do that. I made a new module (Module1 under
the Modules heading) and then put in:
Sub FileSave()
Sunday = Format(WeekStart() + 7, "d")
Saturday = Format(WeekStart() + 13, "d MMM yy")
FileTitle = Sunday & " - " & Saturday & ".doc"
With Dialogs(wdDialogFileSaveAs)
.Name = "J:\Editorial\Magellan\Sickness Absence\Afghan\" &
FileTitle
.Show
End With
End Sub
That didn't do anything.
What is should do (and as far as I can see, you have done it right) is
display the Save dialog predefined when you press Ctrl-S. However, it won't
do that if you have already unlinked the document from the template, as the
template containg the macro is no longer attached to the document!
Therefore, perhaps you need to move the AttachedTemplate command from where
it is and add it to the start of the FileSave macro, so that the template
remains attached until you first save the the document.
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
.
- Follow-Ups:
- Re: Preventing macro from copying over from template to document
- From: chris_huh
- Re: Preventing macro from copying over from template to document
- References:
- Preventing macro from copying over from template to document
- From: chris_huh
- Re: Preventing macro from copying over from template to document
- From: Jonathan West
- Re: Preventing macro from copying over from template to document
- From: chris_huh
- Re: Preventing macro from copying over from template to document
- From: Jonathan West
- Re: Preventing macro from copying over from template to document
- From: chris_huh
- Preventing macro from copying over from template to document
- Prev by Date: Re: Defining a specific range
- Next by Date: Re: Filtering Columns in Word?
- Previous by thread: Re: Preventing macro from copying over from template to document
- Next by thread: Re: Preventing macro from copying over from template to document
- Index(es):
Relevant Pages
|