Excel constants

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

I have been trying to use the following code and Visual
Basic.NET does not seem to recognize "xlDelimited"
and "xlDoubleQuote". Do I need to do something to get
the software to recognize these Excel constants?
Thanks,
Lee

Dim app as Excel.Application
Dim strFileName as String
app = CType(CreateObject("Excel.Application"), _
Excel.Application)
OpenFileDialog1.Filter = "Data (*.txt)|*.txt"
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
strFileName = OpenFileDialog1.FileName
book = app.Workbooks.OpenText(strFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, Space:=True)
app.Visible = True
End If
 
Lee said:
I have been trying to use the following code and Visual
Basic.NET does not seem to recognize "xlDelimited"
and "xlDoubleQuote". Do I need to do something to get
the software to recognize these Excel constants?
Thanks,
Lee

Dim app as Excel.Application
Dim strFileName as String
app = CType(CreateObject("Excel.Application"), _
Excel.Application)
OpenFileDialog1.Filter = "Data (*.txt)|*.txt"
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
strFileName = OpenFileDialog1.FileName
book = app.Workbooks.OpenText(strFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, Space:=True)
app.Visible = True
End If


Use the qualified name instead:
Excel.XlTextParsingType.xlDelimited

You might also consider importing Excel or Excel.XlTextParsingType.

To understand name resolution:
http://msdn.microsoft.com/library/en-us/vbls7/html/vblrfVBSpec4_7.asp
 
Armin,
I appreciate your help but that doesn't seem to solve my
problem. What I am trying to do is open an ASCII data
file in Excel that is space delimited. My problem seems
to be understanding how the OpenText method works in
Excel. I can import the data file into Excel with the
Open method but that will not allow me to set up for
space delimited data. Do you have any idea how to do
this?
Thanks,
Lee
 
Lee said:
Armin,
I appreciate your help but that doesn't seem to solve my
problem.

You wrote that the problem is that the compiler does not recognize
xlDelimited and other constants. My reply does not answer this question?
What I am trying to do is open an ASCII data
file in Excel that is space delimited. My problem seems
to be understanding how the OpenText method works in
Excel. I can import the data file into Excel with the
Open method but that will not allow me to set up for
space delimited data. Do you have any idea how to do
this?

I think this is not the problem you asked in the first posting. As you have
opened a new thread about this problem, I'll try to answer there.
 
Hi Armin,
I'm sorry if I have confused you but I am very new to the
user's group here. Actually, I posted another question as
you noticed, but they are really the same problem. I am
trying to use the OpenText method with an Excel.Workbooks
object and I kept getting the blue underline when I use
xlDelimited in the argument for the OpenText method.

I tried your suggestion but the software tells
me "Expression does not produce a value" for the first
argument of the CType function. I guess I don't know
enough to solve the problem as you suggested.
Regards,
Lee
 
Lee said:
Hi Armin,
I'm sorry if I have confused you but I am very new to the
user's group here. Actually, I posted another question as
you noticed, but they are really the same problem. I am
trying to use the OpenText method with an Excel.Workbooks
object and I kept getting the blue underline when I use
xlDelimited in the argument for the OpenText method.

I'll answer in the other thread.
 
Back
Top