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

MS Word - Reading Text File 1

Status
Not open for further replies.

dodgyone

Technical User
Jan 26, 2001
431
GB
I have a global variable set at the top of the module:

Code:
Public GLBstrEFOLDERID As String

I then have code within Sub AutoOpen() to do this immediately when the document is opened:

Code:
Sub AutoOpen()
    
Dim strReadLine As String
    
If Dir("\\itax-dmdev2\SOAPDownload\Admin.txt") <> "" Then
  
  Open "\\itax-dmdev2\SOAPDownload\Admin.txt" For Output As #1
  Do While Not EOF(1)
    Line Input #1, strReadLine
    If Left(strReadLine, 9) = "EFOLDERID" Then
       GLBstrEFOLDERID = Mid(strReadLine, 11, 31)
    End If
  Loop
  
  Close #1
 
End If
    
MsgBox GLBstrEFOLDERID
       
End Sub

The contents of Admin.txt is:

Code:
EFOLDERID=0000000000000000000000000935691

The problem is that rather than reading the file line by line and putting this into the global variable it is deleting the contents. Any suggestions would be welcomed. Thanks...
 
Replace this:
For Output As #1
with this:
For Input As #1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV. Should of known that... Doh!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top