Hi everyone,
I'm having trouble opening space delimited textfiles in Excel from
Visual Basic.net. I'm able to control, open and modify Excel files
from Visual Basic, so my Excel reference seems to be working ok. I
just don't know what I'm doing when I try to open a space delimited
file and want to put the data into columns. I tried recording a macro
in VBA and going from there, but then I got stuff saying "Name
'xlDelimited' is not declared", etc. So then I started throwing
'Microsoft.Offi ce.Interop.Exce l.XLTextParsing Type.xlDelimite d' in front
because I saw that online somewhere, and things looked like they might
work, but alas, they did not. So here I am. If you haven't figured it
out yet, I'm not a programmer and I'm pretty new to VB, so I would
really appreciate some help on this. I've pasted the not-so-pretty
code I've attempted below solely for your amusement. To be honest, I'm
not even sure what about 90% of it means. With this code I get an
error saying something like "Expression does not produce a value".
Thanks for any help offered.
Dim oExcel As New Microsoft.Offic e.Interop.Excel .Application
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("E xcel.Applicatio n")
oExcel.Visible = True
oBook = oExcel.Workbook s.OpenText("C:\ TextTest.txt",
Origin:=437, StartRow:=1,
DataType:=Micro soft.Office.Int erop.Excel.XlTe xtParsingType.x lDelimited,
TextQualifier:= Microsoft.Offic e.Interop.Excel .XlTextQualifie r.xlTextQualifi erDoubleQuote,
ConsecutiveDeli miter:=True, Tab:=True, Semicolon:=Fals e, _
Comma:=False, Space:=True, Other:=False,
FieldInfo:=Micr osoft.Office.In terop.Excel.XlC olumnDataType.x lGeneralFormat,
TextVisualLayou t:=Microsoft.Of fice.Interop.Ex cel.XlTextVisua lLayoutType.xlT extVisualLTR,
DecimalSeparato r:=".", ThousandsSepara tor:=",",
TrailingMinusNu mbers:=True) 2 10341
Wow. I might have solved my problem accidentally. By taking out the
"oBook =" in front of everything (and just using oExcel as my object),
the text file opened just fine, even without all the mumbo-jumbo after
the filename. My code's this now...
Dim oExcel As New Microsoft.Offic e.Interop.Excel .Application
oExcel = CreateObject("E xcel.Applicatio n")
oExcel.Visible = True
oExcel.Workbook s.Open("C:\Text Test.txt")
I assume then that I must just not be dimensioning something correctly.
I wonder why the program knows it's a space delimited file, since as
you can see I haven't stated that anywhere in my code. Thoughts? Ja**********@ec .gc.ca wrote:
Hi everyone,
I'm having trouble opening space delimited textfiles in Excel from
Visual Basic.net. I'm able to control, open and modify Excel files
from Visual Basic, so my Excel reference seems to be working ok. I
just don't know what I'm doing when I try to open a space delimited
file and want to put the data into columns. I tried recording a macro
in VBA and going from there, but then I got stuff saying "Name
'xlDelimited' is not declared", etc. So then I started throwing
'Microsoft.Offi ce.Interop.Exce l.XLTextParsing Type.xlDelimite d' in front
because I saw that online somewhere, and things looked like they might
work, but alas, they did not. So here I am. If you haven't figured it
out yet, I'm not a programmer and I'm pretty new to VB, so I would
really appreciate some help on this. I've pasted the not-so-pretty
code I've attempted below solely for your amusement. To be honest, I'm
not even sure what about 90% of it means. With this code I get an
error saying something like "Expression does not produce a value".
Thanks for any help offered.
Dim oExcel As New Microsoft.Offic e.Interop.Excel .Application
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("E xcel.Applicatio n")
oExcel.Visible = True
oBook = oExcel.Workbook s.OpenText("C:\ TextTest.txt",
Origin:=437, StartRow:=1,
DataType:=Micro soft.Office.Int erop.Excel.XlTe xtParsingType.x lDelimited,
TextQualifier:= Microsoft.Offic e.Interop.Excel .XlTextQualifie r.xlTextQualifi erDoubleQuote,
ConsecutiveDeli miter:=True, Tab:=True, Semicolon:=Fals e, _
Comma:=False, Space:=True, Other:=False,
FieldInfo:=Micr osoft.Office.In terop.Excel.XlC olumnDataType.x lGeneralFormat,
TextVisualLayou t:=Microsoft.Of fice.Interop.Ex cel.XlTextVisua lLayoutType.xlT extVisualLTR,
DecimalSeparato r:=".", ThousandsSepara tor:=",",
TrailingMinusNu mbers:=True)
Hi Jacob,
Would you like to try OrchidGrid, which can parse/import delimited text
files and transfer/export the data to Excel?
Check this, http://www.springsys.com/netproducts/orchid.asp
Hi everyone,
I'm having trouble opening space delimited textfiles in Excel from
Visual Basic.net. I'm able to control, open and modify Excel files
from Visual Basic, so my Excel reference seems to be working ok. I
just don't know what I'm doing when I try to open a space delimited
file and want to put the data into columns. I tried recording a macro
in VBA and going from there, but then I got stuff saying "Name
'xlDelimited' is not declared", etc. So then I started throwing
'Microsoft.Offi ce.Interop.Exce l.XLTextParsing Type.xlDelimite d' in front
because I saw that online somewhere, and things looked like they might
work, but alas, they did not. So here I am. If you haven't figured it
out yet, I'm not a programmer and I'm pretty new to VB, so I would
really appreciate some help on this. I've pasted the not-so-pretty
code I've attempted below solely for your amusement. To be honest, I'm
not even sure what about 90% of it means. With this code I get an
error saying something like "Expression does not produce a value".
Thanks for any help offered.
Dim oExcel As New Microsoft.Offic e.Interop.Excel .Application
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("E xcel.Applicatio n")
oExcel.Visible = True
oBook = oExcel.Workbook s.OpenText("C:\ TextTest.txt",
Origin:=437, StartRow:=1,
DataType:=Micro soft.Office.Int erop.Excel.XlTe xtParsingType.x lDelimited,
TextQualifier:= Microsoft.Offic e.Interop.Excel .XlTextQualifie r.xlTextQualifi erDoubleQuote,
ConsecutiveDeli miter:=True, Tab:=True, Semicolon:=Fals e, _
Comma:=False, Space:=True, Other:=False,
FieldInfo:=Micr osoft.Office.In terop.Excel.XlC olumnDataType.x lGeneralFormat,
TextVisualLayou t:=Microsoft.Of fice.Interop.Ex cel.XlTextVisua lLayoutType.xlT extVisualLTR,
DecimalSeparato r:=".", ThousandsSepara tor:=",",
TrailingMinusNu mbers:=True) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Carl Mercier |
last post by:
Hi!
I have written a little class in .NET to convert a DataTable or a
dataView to a comma-delimited text file. This file eventually gets
imported in Excel or Word.
Everything works great, I handled commas and quotes and Excel reads my
files correctly. I have one little problem, though... If a field in the
datatable has a carriage return...
|
by: mr_ocp |
last post by:
Hi friends
I need routines to create an excel file with worksheets for each
customer and a text file as well for each customer, first worksheet
would be a "Summary Report", here is the code that would get the data
for me I would appreciate if someone can add routines to create excel
and text files to it, the columns in text file need to be...
|
by: Bernie Yaeger |
last post by:
Is there a way to convert or copy a .xml file to a comma delimited text file
using vb .net?
Thanks for any help.
Bernie Yaeger
|
by: iwdu15 |
last post by:
how can i open a file i saved and place the info into different text boxes?
|
by: Avi |
last post by:
I need to create a text file that has the data from the 10 tables in
the database. The number of fields in the tables exceeds 255 and so I
cannot make a new table with all the fields and then export it into a
text file.
Is there any s/w out there I could use? I am not much of a programmer
but I heard I could use VBA to get this done. Any help...
| |
by: =?Utf-8?B?UmljaA==?= |
last post by:
'--this code works but only reads text into one column when contains multiple
cols
Dim ds1x As New DataSet
Dim ConStr As String = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dir1A\;Extended
Properties=""Text;HDR=No;FMT=Delimited\"""
Dim conn1x As New OleDb.OleDbConnection(ConStr)
Dim dax1 As New OleDbDataAdapter("Select * from...
|
by: Ted Theo |
last post by:
hello cdma enthusiasts. long time no speak. i have an .adp which is
connected to a sql 2k back end from which i need to export a table to
a tab delimited text file. the export text wizard apparently doesn't
allow you to store export specs (makes sense since it has no local
storage) so i'm not sure the TransferText method is going to do the...
|
by: Phil Stanton |
last post by:
I have a form with a button which is supposed to open an Excel file (With
lots of Macros /VBA) in it. The Excel file gets it's data from the Access
program
Here is the code
Private Sub Storage_Click()
On Error GoTo Err_Storage_Click
|
by: asedt |
last post by:
With my Excel macro and two text files I want to create a new textfile containing the first textfile then text from the sheet and then the second textfile.
My problem is that i don't know how to append the second textfile.
Sub mysub()
Dim TempString As String
'Open the first file
Dim fileA As Integer
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |