Opening a dotx file as read only

Renee08

New member
Joined
Nov 26, 2008
Messages
2
Programming Experience
3-5
Currently I am creating a new Word document within the vb.net code and using AttachedTemplate to indicate what template the document should be based on.

It's possible for more than one person to be doing this at once, but the second person to run this code gets the "Locked for editing" dialog with the option of opening the template as Read only etc.

What I want to do is set the template to open/be attached as a read-only version (i.e. the equivalent of clicking "ok" to the Read only option). Is this possible?

A small sample of the code:

myWordDoc = myWordApp.Documents.Open(fullName, False, False, False)
myWordDoc .AttachedTemplate = strTemplateFilename

Thanks.
 
With a bit of help I've found an answer:

If IO.Path.GetExtension(strTemplateFilename) = ".dotx" Or IO.Path.GetExtension(strTemplateFilename) = ".dotm" Then
IO.File.SetAttributes(strTemplateFilename, IO.FileAttributes.ReadOnly)
End If

It seems very obvious now!
 
Back
Top