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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open text file Read Only

Status
Not open for further replies.

FoxProProgrammer

Programmer
Apr 26, 2002
967
US
Hi,

The following code opens a text file using Notebook.

Code:
Dim File As String
Dim RetVal

File = "c:\Program Files\SCADC Repair Tracking\release.txt"

RetVal = Shell("c:\windows\notepad.exe " & File, 1)    ' Run Notepad.

If RetVal = 0 Then
    MsgBox "Release Notes file not found!", vbCritical + vbOKOnly, "SCADC Repair Tracking"
End If

1. Is there a way to open the file as Read Only? I set the file attributes to Read Only, but I want to prevent the user from typing text in the Notepad window. Is there a way to do this, or do I need to create an Access Form instead of using a text file?

2. I changed the name of the file to see if RetVal would be 0. It doesn't work. Instead, a dialog is displayed that the file couldn't be found...Do you want to create a new file... Is there a way to disable that? Do I need to trap this error and handle it in an error handler?

Thanks!



dz
 
If the notes are quite small, I suppose you could use a message box:

Code:
Dim fs As FileSystemObject

Set fs = CreateObject("Scripting.FileSystemObject")
 
Set f = fs.OpenTextFile(DT & "x.txt")

a = f.ReadAll

MsgBox a

However, I think you would be better off with a form.
 
Thanks, Remou. I was trying to get fancy with Notepad, but I guess it's easier to use a form.

Best wishes,


dz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top