When the .doc file is locked for editing?

A

Andrew

Hi, friends,

When running the following code, I got an error at line msdoc.Close (see
code below)

Run-time error -2147417851(80010105)

Dim mswd As New Word.Application
Dim msdoc As Word.Document

Set msdoc = mswd.Documents.Open("c:\templateHF.doc")
msdoc.Range.InsertFile "c:\CQInfo.doc"

msdoc.Close
mswd.Quit

As a result, could not open file TemplateHF.doc anymore. It said this file is
locked for editing.

(If before msdoc.Close, I add: msdoc.SaveAs "c:\new.doc", this new.doc is
locked for edition too).

Any ideas? Thanks.
 

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