N
news.microsoft.com
Hi
I'm writing a Workbook_Open() macro to open a text file and read in some
configuration data when an Excel workbook opens:
Private Sub Workbook_Open()
Dim inifile As String
inifile = "c:\test.ini"
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists(inifile) Then
Set f = fs.OpenTextFile(inifile, ForReading, TristateFalse)
f.Close
End If
End Sub
It all works perfect until the call to OpenTextFile(..), which generates an
error message:
Run-time error '5':
Invalid procedure call or argument.
I use the FileSystemObject successfully to open files in other macros in the
same workbook,
so I do not understand why it fails here.
Any suggestions..?
Einar Værnes
I'm writing a Workbook_Open() macro to open a text file and read in some
configuration data when an Excel workbook opens:
Private Sub Workbook_Open()
Dim inifile As String
inifile = "c:\test.ini"
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists(inifile) Then
Set f = fs.OpenTextFile(inifile, ForReading, TristateFalse)
f.Close
End If
End Sub
It all works perfect until the call to OpenTextFile(..), which generates an
error message:
Run-time error '5':
Invalid procedure call or argument.
I use the FileSystemObject successfully to open files in other macros in the
same workbook,
so I do not understand why it fails here.
Any suggestions..?
Einar Værnes