Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Viewed Notepad File to Read-Only 1

Status
Not open for further replies.

squirleegirl

Programmer
Jun 24, 2003
59
US
I am new at this...so please be patient with me =-)

I have an Access Database that is displaying a .txt file in Notepad (through the shell command) for viewing.

How can I make this file read-only? This is the code I am using....

Shell "notepad.exe C:\Documents and Settings\" & cboFindStudentID.Value & "\My Documents\" & Combo214.Value & ".txt", vbNormalFocus

Thanks!!!!!
 
I'd be tempted to copy the file to a known temporary filename, like c:\~temp.txt, and then run Notepad. You would call the Shell function to Command.com (Shell Command.com /c COPY Filename C:\~Temp.txt), but then you need to wait until the Shell process ends before calling Notepad (another topic). If they save C:\~Temp.txt, who cares?
You could use the SetAttr method of Access to set file to read only before opening (SetAttr "Filename", vbReadOnly), but then you'd have to set it back to vbNormal after they close Notepad. And what if their machine locks up? File will be left as vbReadOnly. And user may unintentionally make a change and be prompted to save, which they won't be able to unless under a different name, which may begin to create other problems. Kinda messy....Go for the copy solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top