Brilliant. Duh. Well, I might be back.
Thanks Graham!
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Wednesday, November 02, 2016 4:41 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] reading a text file
Hi Liz
Remove the quotes from this line:
Set MyFile = fso.OpenTextFile("strFname", 1)
Best wishes,
Graham
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Thursday, 3 November 2016 12:28
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] reading a text file
Under the gun so I could use some help.
I’m trying to read a text file and it is ! saying file not found.
I have a browse button that returns this to a text file:
Function LaunchCD(strform As Form) As String
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
sFilter = "Txt: (*.txt)"
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
O! penFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "C:\"
OpenFile.lpstrTitle = "Select a file using the Common Dialog DLL"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, _
"Select a file using the Common Dialog DLL"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1, OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
.And then gets passed to this after a submit button:
Sub ReadTheFile(strFname As String)
On Error GoTo err_out
Dim linetxt As String
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("strFname", 1)
linetxt = MyFile.ReadLine
MsgBox (linetxt)
GoTo exit_out
e! rr_out:
MsgBox ("Error in ReadTheFile: " & Err.Number & vbCrLf & Err.Description)
exit_out:
'bye
End Sub
Any ideas?
p.s. the code is scrappy because I’m testing as I go.
Respectfully,
Liz Ravenwood
Programmer / Analyst
B/E Aerospace | Super First Class Environments
1851 S Pantano Road | Tucson, Arizona 85710
Office +1.520.239.4808 | Internal 814-4808
beaerospace.com
Passion to Innovate. Power to Deliver!
This email (and all attachments) is for the sole use of the intended recipient(s) and may contain privileged and/or proprietary information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
This email (and all attachments) is for the sole use of the intended recipient(s) and may contain privileged and/or proprietary information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
Posted by: Liz Ravenwood <Liz_Ravenwood@beaerospace.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
Tidak ada komentar:
Posting Komentar