Hi,

I have a piece of VBA code that updates styles in a document. The problem is
every time this code executes, the base template is changed and I'm prompted
to save it. What I want is for the change to only apply to the current
document.

An example of the code is
If langUK Then
ActiveDocument.Styles("Normal").LanguageID = wdEnglishUK
Else
If langUS Then
ActiveDocument.Styles("Normal").LanguageID = wdEnglishUS
ActiveDocument.PageSetup.PaperSize = wdPaperLetter
Else
ActiveDocument.Styles("Normal").LanguageID = wdEnglishAUS
End If

Re: VBA Style Changes Effecting Template by Doug

Doug
Tue Feb 26 01:20:36 PST 2008

Try using the following code after your If...End If

Dim temp As Template
Set temp = ActiveDocument.AttachedTemplate
temp.Saved = True
Set temp = Nothing


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Geoff332" <Geoff332@discussions.microsoft.com> wrote in message
news:C22B8F67-4C9E-4C1C-B22D-39AEA7641D4C@microsoft.com...
> Hi,
>
> I have a piece of VBA code that updates styles in a document. The problem
> is
> every time this code executes, the base template is changed and I'm
> prompted
> to save it. What I want is for the change to only apply to the current
> document.
>
> An example of the code is
> If langUK Then
> ActiveDocument.Styles("Normal").LanguageID = wdEnglishUK
> Else
> If langUS Then
> ActiveDocument.Styles("Normal").LanguageID = wdEnglishUS
> ActiveDocument.PageSetup.PaperSize = wdPaperLetter
> Else
> ActiveDocument.Styles("Normal").LanguageID = wdEnglishAUS
> End If
>
>



Re: VBA Style Changes Effecting Template by Geoff332

Geoff332
Tue Feb 26 14:15:01 PST 2008

Thanks a lot: that's a very useful piece of code to stop people saving the
template. I'd also confused references to 'ThisDocument' and 'ActiveDocument'
which wasn't helping.

"Doug Robbins - Word MVP" wrote:

> Try using the following code after your If...End If
>
> Dim temp As Template
> Set temp = ActiveDocument.AttachedTemplate
> temp.Saved = True
> Set temp = Nothing
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Geoff332" <Geoff332@discussions.microsoft.com> wrote in message
> news:C22B8F67-4C9E-4C1C-B22D-39AEA7641D4C@microsoft.com...
> > Hi,
> >
> > I have a piece of VBA code that updates styles in a document. The problem
> > is
> > every time this code executes, the base template is changed and I'm
> > prompted
> > to save it. What I want is for the change to only apply to the current
> > document.
> >
> > An example of the code is
> > If langUK Then
> > ActiveDocument.Styles("Normal").LanguageID = wdEnglishUK
> > Else
> > If langUS Then
> > ActiveDocument.Styles("Normal").LanguageID = wdEnglishUS
> > ActiveDocument.PageSetup.PaperSize = wdPaperLetter
> > Else
> > ActiveDocument.Styles("Normal").LanguageID = wdEnglishAUS
> > End If
> >
> >
>
>
>