[AccessD] Read the contents of a file into a memvar

Heenan, Lambert Lambert.Heenan at AIG.com
Fri Jul 8 15:39:54 CDT 2005


Try this...

Function ReadFile(strFilePath As String) As String
Dim strFileName As String
Dim nLength As Long
Dim fh As Long
    strFileName = Dir(strFilePath)
    If strFileName & "" = "" Then
        ReadFile = ""
    Else
        nLength = FileLen(strFilePath)
        fh = FreeFile
        Open strFilePath For Input As #fh
        ReadFile = Input(nLength, #fh)
        Close #fh
    End If
End Function

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: Friday, July 08, 2005 3:52 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Read the contents of a file into a memvar


I need to do what the subject says. The file might possibly be 1000 chars
but more likely fewer. What I would ideally like to do is this:

Dim myText as string
Dim strSourceFile as string
strSourceFile = xxxx
myText = ReadFile( strSourceFile )

And then, once I am done, post said text to a Word bookmark... but that part
is easy.

TIA,
Arthur

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list