I see your problem. And true, Word can not store protect information on a text file. And true, as PHV mentions, Windows can. So, if you want to be sneaky......
You do not state what you have in Word that is going to open the text file. Obviously you must have a document (even a blank one) open. I am further assuming you are running the open code from normal.dot. Although you could be doing it from a global template.
In any case, you could, if you want to be sneaky, run code that will set
Windows file attributes on the text file. You could make it Read-Only,
then open it.
Not sure it would be worth the bother, but you could do it. Like this:
Code:
Dim fso As Scripting.FileSystemObject
Dim fil As Scripting.File
Set fso = CreateObject("Scripting.FileSystemObject")
Set fil = fso.GetFile("c:\myfiles\TestTxt.txt")
If fil.Attributes = 0 Then
fil.Attributes = fil.Attributes + 1
End If
Set fil = Nothing
Set fso = Nothing
Documents.Open FileName:="c:\myfiles\testtxt.txt"
The text file will open in Word as Read-Only. You need a reference to Scripting Run-time to use FileSystemObject, but that is not a big deal.
NOTE: the above assumes there are NO other file attributes (Attributes = 0). Correct procedure would be to
check first. Also, this is not temporary. This actually sets the file attribute to read-only.
faq219-2884
Gerry
My paintings and sculpture