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

rusty.hammond at cpiqpc.com rusty.hammond at cpiqpc.com
Fri Jul 8 15:59:25 CDT 2005


Can't disagree with you there.  I just got in an hurry and focused on the
code to get the file text into a variable.  Should have spent an extra
minute or two on it.  

thanks

-----Original Message-----
From: Heenan, Lambert [mailto:Lambert.Heenan at aig.com]
Sent: Friday, July 08, 2005 3:51 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Read the contents of a file into a memvar


This code will not work because you do not assign the value of strFileText
to the name of the function (which is how you make a function return
something). Also you did not declare the function return type, so it will
default to a Variant. Not that that would prevent the function for working.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
rusty.hammond at cpiqpc.com
Sent: Friday, July 08, 2005 4:42 PM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Read the contents of a file into a memvar


Arthur,
If the file you're reading is just a simple text file, then the following
should work:

Function ImportTextFileIntoVar()

    Dim strTextLine
    Dim strFileText As String
    Dim strFileName As String
    
    strFileName = "i:\test.txt"
    
    Open strFileName For Input As #1
    
    Do While Not EOF(1)
        Line Input #1, strTextLine
        strFileText = strFileText & vbCrLf & strTextLine
    Loop
        
    Close 1

End Function

Rusty

-----Original Message-----
From: Arthur Fuller [mailto:artful at rogers.com]
Sent: Friday, July 08, 2005 2: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

**********************************************************************
WARNING: All e-mail sent to and from this address will be received, scanned
or otherwise recorded by the CPI Qualified Plan Consultants, Inc. corporate
e-mail system and is subject to archival, monitoring or review 
by, and/or disclosure to, someone other than the recipient.
**********************************************************************
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

**********************************************************************
WARNING: All e-mail sent to and from this address will be received,
scanned or otherwise recorded by the CPI Qualified Plan Consultants, Inc.
corporate e-mail system and is subject to archival, monitoring or review 
by, and/or disclosure to, someone other than the recipient.
**********************************************************************



More information about the AccessD mailing list