ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   open a text file (https://www.excelbanter.com/excel-programming/390817-open-text-file.html)

lumpy04

open a text file
 
Hello,

I have a check list that we use to verify computer builds. I would like to
write code for a checkbox that wouls open a text file on a server. I have
tried 2 ways, neither work.
Private Sub Printers_Click()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f =
fs.OpenTextFile("\\usshl2-dplfsd01\data$\documentation\printers.txt",
ForAppending, TristateFalse)

End Sub


open \\usshl2-dplfsd01\data$\documentatio\printers.txt for random as #1

There must be a simple solution.....

TIA,
Mike

NickHK

open a text file
 
VBA built in routines should be sufficient.
If this is an ANSI text file, then don't open in binary.
Also, is that path correct ? "documentatio"
The path/filename is a string, so enclose it in quotes.
And look at FreeFile in the help

Dim FileNum As Long
FileNum = FreeFile
Open "\\usshl2-dplfsd01\data$\documentation\printers.txt" For Input As
#FileNum
'...etc

NickHK

"lumpy04" wrote in message
...
Hello,

I have a check list that we use to verify computer builds. I would like to
write code for a checkbox that wouls open a text file on a server. I have
tried 2 ways, neither work.
Private Sub Printers_Click()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f =
fs.OpenTextFile("\\usshl2-dplfsd01\data$\documentation\printers.txt",
ForAppending, TristateFalse)

End Sub


open \\usshl2-dplfsd01\data$\documentatio\printers.txt for random as #1

There must be a simple solution.....

TIA,
Mike





All times are GMT +1. The time now is 05:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com