Hi,
I am having difficulties with what perhaps should be a simple VB programming task, using the ShowOpen Method of the Common control dialog box. I have looked at many beginner books and have reduced the coding to the following to help debug the code. I have attempted to use a filter to open 'txt' files created in Notepad.
When I use the dialog the 'Files of Type box' drop-down is empty -not populated. double clicking on a file gives error Message 53: file Not found. Suprising because a text file 'Log.txt', created in notepad actually exists in the location selected using the Fileopen Dialog. If I set a breakpoint over strFileName the path "c:\temp\log.txt" is correctly contained in the variable. I have tried 'shelling' directly using this path/filename but still get the same error message.
The code is part of a database programming application which logs particular records to a text file. this part ironically the complex part using ADO recordsets works fine!
in summary, I simply want to double click on a txt file selected by the user and it is launched using Notepad.
So, having reduced the problem with still no 'joy', can anyone help identify my problem?
Many thanks in anticipation.
I am having difficulties with what perhaps should be a simple VB programming task, using the ShowOpen Method of the Common control dialog box. I have looked at many beginner books and have reduced the coding to the following to help debug the code. I have attempted to use a filter to open 'txt' files created in Notepad.
When I use the dialog the 'Files of Type box' drop-down is empty -not populated. double clicking on a file gives error Message 53: file Not found. Suprising because a text file 'Log.txt', created in notepad actually exists in the location selected using the Fileopen Dialog. If I set a breakpoint over strFileName the path "c:\temp\log.txt" is correctly contained in the variable. I have tried 'shelling' directly using this path/filename but still get the same error message.
The code is part of a database programming application which logs particular records to a text file. this part ironically the complex part using ADO recordsets works fine!
in summary, I simply want to double click on a txt file selected by the user and it is launched using Notepad.
So, having reduced the problem with still no 'joy', can anyone help identify my problem?
Many thanks in anticipation.
Code:
Private Sub cmdOpenFiles_Click()
Dim StrFileName As String
dbTextFiles.ShowOpen
dbTextFiles.Filter = "Text Files (*.txt)|.txt"
StrFileName = dbTextFiles.FileName
lblFileName.Caption = StrFileName
Shell "notepad.exe" & "StrFileName", vbNornalFocus
End Sub