Link to home
Start Free TrialLog in
Avatar of hke72
hke72Flag for Norway

asked on

Asked to save Normal.dot; 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 Normal.dot 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 normal.dot, but never changes it and therefore never has this problem?
Private Sub btnWord_Click()
    Dim WApp As New Word.Application
    Me.Refresh
   With WApp
      .Visible = True
      .WindowState = wdWindowStateMaximize
      .Documents.Add Template:=(CurrentProject.Path & conTEMPLATE_NAME)
   End With
   Set WApp = Nothing
End Sub

Open in new window

Avatar of deadlyDev
deadlyDev
Flag of Spain image

I think this is because you are adding the actual template as the document to edit (Normal.dot 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...
Avatar of Patrick Matthews
deadlyDev said:
>>I think this is because you are adding the actual template as the document to edit (Normal.dot 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...
deadlyDev said:
>>My Apologies... it has been a while since I worked with this...

:)
ASKER CERTIFIED SOLUTION
Avatar of Leigh Purvis
Leigh Purvis
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start 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.
Avatar of hke72

ASKER

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?
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?
e.g.
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.
Avatar of hke72

ASKER

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!
Avatar of hke72

ASKER

I do not know why assigning the property directly did not work, but LPurvis your solution worked. Thank you!