Asked to save; Word and Access

I use Windows XP with Office 2003. From MS Access i start a Word-document. This doc reads data from the Access-database using ADO. When closing Word I always get the message that has been changed and if I want to save changes.

My biggest problem is that it does not happen on my laptop only on the customer LAN.

Is there something strange with my code? Is it possible she does not have rights to, but never changes it and therefore never has this problem?
Private Sub btnWord_Click()
    Dim WApp As New Word.Application
   With WApp
      .Visible = True
      .WindowState = wdWindowStateMaximize
      .Documents.Add Template:=(CurrentProject.Path & conTEMPLATE_NAME)
   End With
   Set WApp = Nothing
End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think this is because you are adding the actual template as the document to edit ( is the default word template.)

I believe you would need to create a new document that is a copy of the template and add that to the documents collection...
Patrick MatthewsCommented:
deadlyDev said:
>>I think this is because you are adding the actual template as the document to edit ( is the
>>default word template.)

With respect, that is incorrect.  Documents.Add, when used with a template argument, does not open the
template for editing--rather, it creates a new Document object that is based on the template.
My Apologies... it has been a while since I worked with this...
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Patrick MatthewsCommented:
deadlyDev said:
>>My Apologies... it has been a while since I worked with this...

Leigh PurvisDatabase DeveloperCommented:
I've heard many suggested reasons for this behaviour (from Outlook being open - and using Word as its default editor) to simple Template manipulation "dirtying" Normal.Dot in the process (FWIW I've seen the behaviour without Outlook being open or Word as its default editor).
Ultimately - you can remove the edited flag on the tempate by specifying that it is not so.
(I once gave up too early in my attempt to do so - because Word doesn't always recognise Normal as a named member of its Templates collection - even though it is present).
Consequently you just need to enumerate the collection checking for (or Normal.dotm in 2007 +)
    Dim objTemp As Object

    For Each objTemp In objWord.Templates
        If Left(objTemp.Name, 10) = "" Then
            objTemp.Saved = True
            Exit For
        End If
To allow somewhat for the name difference in recent versions.
(Though that's not necessarily great generic advice as what if someone had a template named "" ? :-s).
In that eventuality you could comment out the "Exit For" so that it at least got around to both. ;-)

See how you go.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
There is an option in Word to request that prompt:
Tools/Options, Save tab, 'Prompt to save Normal template' checkbox.

Actually Leigh, the Word Application object has NormalTemplate property, so there isn't a need to look at the Templates collection. If you wanted to pre-empt the message,

objWord.NormalTemplate.Saved = True

should do it.
hke72Author Commented:
Thank you for all the help. I am currently testing your ideas.
To GrahamSkan
I get "Expected function or variable" running this code both from my Access-db and in the word-doc-code?
Any idea?
Leigh PurvisDatabase DeveloperCommented:
Nice to see that Normal is special enough to have merited its own property that will accomplish the same task without the enumeration.
(I'd expect that's as reliable as the enumeration and not as "flighty" as being a named member of the collection? ;-)
hke72 - you have a Word application object variable named objWord?
Dim objWord As Word.Application
'... whatever manipulation...
objWord.NormalTemplate.Saved = True
Sorry hke72

I used objWord as the Application variable. I now see that you are using WApp, so it should be:
Wapp.NormalTemplate.Saved = True

It is recommended that you always have Option Explicit at the top of each module. Then the error would have been Variable not defined, which gives you a better idea about what is wrong.
hke72Author Commented:
Hi GrahamSkan,
I did change the name so that did not seem to be the problem. Anyway I used LPurvis solution and it worked.
Thank you!
hke72Author Commented:
I do not know why assigning the property directly did not work, but LPurvis your solution worked. Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.