Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default running text import wizard through c#

I have a data file that I need to download and convert from text to xls to
then do further manipulation. When I manually fire up excel, open the text
file and leave all the text import wizard defaults I can then work with the
resulting xls file programmatically. When I use the following code I get
errors when I try to open the resulting xls file. I haven't been able to
find much about the different options in the OpenText file command so I'm not
sure what properties I'm setting incorrectly that the wizard automatically
sets correctly. It's a tab delimited file. Can anyone tell me what options
I need to set to get it converted correctly? Thanks.

Excel.Application application = new Excel.Application();
object missing = System.Reflection.Missing.Value;
System.Threading.Thread.CurrentThread.CurrentCultu re = new
CultureInfo("en-US");
System.Threading.Thread.CurrentThread.CurrentUICul ture = new
CultureInfo("en-US");
application.Caption = "Test";
application.Visible = true;
application.Workbooks.OpenText
(
sFileToSave,
missing,
1,
Excel.XlTextParsingType.xlDelimited,
Excel.XlTextQualifier.xlTextQualifierNone,
missing,
true, //TAB
missing,
false, //COMMA
missing,
missing,
missing,
missing,
missing,
missing,
missing,
missing,
missing
);

application.Save(sExcelToSave);
application.Quit();
application = null;
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text Import Wizard perplexIN Excel Discussion (Misc queries) 2 March 4th 09 11:45 AM
How to Start Excel in Text Import Wizard for data import rlelvis Setting up and Configuration of Excel 0 July 10th 08 08:40 PM
Text Import Wizard bozinomi Excel Discussion (Misc queries) 1 November 9th 06 01:25 PM
Text Import Wizard Prema Excel Discussion (Misc queries) 3 April 5th 06 03:11 PM
Text Import Wizard from vba Ömer Ayzan Excel Programming 2 April 8th 05 08:29 AM


All times are GMT +1. The time now is 10:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"