Hi,
I've created a dll that reads a textfile. The dll compiles fine, but when I try to use it in Excel - by reference to the .tlb file - I get an error "The filename, directory name, or volume label syntax is incorrect". It works nicely when I try something simple like if the dll takes an integer and adds 2, but not when reading the file. The code looks like this:
C#
using System;
using System.IO;
public class TestExcelDLL
{
public string test()
{
TextReader myStream=new StreamReader("c:\testdata.txt");
return myStream.ReadLine();
}
}
VBA
Sub test()
Dim x As ExcelDLL.TestExcelDLL
Set x = New ExcelDLL.TestExcelDLL
Range("b2").Value = x.test
Set x = Nothing
End Sub
I know that there are variable limitations - like that you cannot have array because they're varArrays in Excel etc - but I haven't heard anything about reading a textfile. I need to go this way because I want a large chunk of data in my dll and it doesn't take varArrays to my knowledge. Thx in advance.
I've created a dll that reads a textfile. The dll compiles fine, but when I try to use it in Excel - by reference to the .tlb file - I get an error "The filename, directory name, or volume label syntax is incorrect". It works nicely when I try something simple like if the dll takes an integer and adds 2, but not when reading the file. The code looks like this:
C#
using System;
using System.IO;
public class TestExcelDLL
{
public string test()
{
TextReader myStream=new StreamReader("c:\testdata.txt");
return myStream.ReadLine();
}
}
VBA
Sub test()
Dim x As ExcelDLL.TestExcelDLL
Set x = New ExcelDLL.TestExcelDLL
Range("b2").Value = x.test
Set x = Nothing
End Sub
I know that there are variable limitations - like that you cannot have array because they're varArrays in Excel etc - but I haven't heard anything about reading a textfile. I need to go this way because I want a large chunk of data in my dll and it doesn't take varArrays to my knowledge. Thx in advance.