Re: Can not save Normal.dot error when automating Word from VBScript
From: Javed (javed.hussain_at_gonetbpo.com)
Date: 12/27/04
- Previous message: Javed: "Re: Managed Addin problem."
- In reply to: Viatcheslav V. Vassiliev: "Can not save Normal.dot error when automating Word from VBScript"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 27 Dec 2004 12:04:07 +0500
why do you want to save it manually, Word manages to save the changes in
Normal.dot itself. The thing is that its a Global Template and used by all
the instances at the same time and u cant save it with other instances of
word open. Either dont save it and the word will save it iteself when all
the instances are closed or u can set the Saved property of NormalTemplate
to false manually to make it sure that word saves the changes at the end.
i.e.
WordApplicationObject.NormalTemplate.Saved = false ;
hope it will help
regards
--
Javed hussain
Software Developer
GoNetBPO (Pvt.) Ltd.
UAN: +92-21-111-276-111
Tel: +92-21-4391340-7 Ext: 407
Cell: 0300-2659032 Fax:+92-21-4547129
javed.hussain@gonetbpo.com
www.GoNetBPO.com
"Viatcheslav V. Vassiliev" <msnewsgroup@www-sharp.com> wrote in message
news:eJsS3M64EHA.1404@TK2MSFTNGP11.phx.gbl...
> When the script below runs, Word raises error "Word cannot save this file
> because it is already open elsewhere. (C:\Documents and
> Settings\...\Normal.dot)". This happens only when another document is
> already open in Word before starting script. If Word is not open, script
> runs OK. Any combination of word.NormalTemplate.Saved = true,
> doc.Application.NormalTemplate.Saved = true, doc.AttarchedTemplate.Saved =
> true does not help. The error happens on one computer but does not on
> another.
>
> What could be the readson for this error and how to resolve it?
>
> '---------------------test.vbs-----------------
> dim word, doc, rng
> set word = CreateObject("Word.Application")
> word.DisplayAlerts = 0
> word.Visible = true
> set doc = word.Documents.Add
> set rng = doc.Range(0, 0)
> rng.InsertBefore("Some text")
> rng.InsertParagraphAfter()
> set rng = nothing
> 'doc.Application.NormalTemplate.Saved = true
> 'doc.AttachedTemplate.Saved = true
> doc.SaveAs "C:\temp\vbs_test.doc"
> 'doc.Application.NormalTemplate.Saved = true
> 'doc.AttachedTemplate.Saved = true
> set doc = nothing
> word.NormalTemplate.Saved = true
> word.Quit
> set word = nothing
> MsgBox "Done"
> '---------------------test.vbs-----------------
>
> Best regards,
> Viatcheslav V. Vassiliev
>
>
>
- Previous message: Javed: "Re: Managed Addin problem."
- In reply to: Viatcheslav V. Vassiliev: "Can not save Normal.dot error when automating Word from VBScript"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|