VBA Style Changes Effecting Template

G

Geoff332

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
 
D

Doug Robbins - Word MVP

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
 
G

Geoff332

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.
 

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