LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel VBA to VB.NET conversion

I have the following code in Excel VBA that I'm trying to convert to VB.NET:

Workbooks.OpenText(Filename:= _
"C:\temp.txt", Origin:=437, StartRow:= _
1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, TAB:=False, Semicolon:=False, Comma:=True _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2), Array(2, 2), _
Array(3, 2), Array(4, 1)), TrailingMinusNumbers:=True)

I've converted everything except the array portion (arrColumnDataType shown
below with ???). I'm having a problem coming up with the proper array in
VB.NET to put in this code:

Dim xlApp As New Excel.Application
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlApp.Application.Visible = True
Dim strReportName As String = "C:\temp.txt"

??? How do I define arrColumnDataType ???

xlApp.Workbooks.OpenText(strReportName, 437, 1, _
Excel.XlTextParsingType.xlDelimited, _
Excel.XlTextQualifier.xlTextQualifierDoubleQuote, False, False, False, _
True, False, False, False, arrColumnDataType, , , , , True)

I know that the array is defined as (column number, format) where format is:
Excel.XlColumnDataType.xlGeneralFormat = 1
Excel.XlColumnDataType.xlTextFormat = 2
Excel.XlColumnDataType.xlMDYFormat = 3
Excel.XlColumnDataType.xlDMYFormat = 4
Excel.XlColumnDataType.xlYMDFormat = 5
Excel.XlColumnDataType.xlMYDFormat = 6
Excel.XlColumnDataType.xlDYMFormat = 7
Excel.XlColumnDataType.xlYDMFormat = 8
Excel.XlColumnDataType.xlSkipColumn = 9

I just can't seem to get a proper array setup that the compiler likes. Does
anyone have a suggestion? Has anyone coded this type of project with success.
I'm using VS 2005, but I just upgraded about two weeks ago. Is there an
easier way in 2.0? Thanks
--
Lost in the Vast Sea of .NET
 
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
Excel Conversion RFB New Users to Excel 2 January 11th 10 08:12 PM
Excel conversion to PDF? Sigi Rindler Excel Discussion (Misc queries) 1 October 27th 06 02:53 PM
Excel conversion Realstar New Users to Excel 1 January 31st 06 11:34 PM
Excel to PDF conversion in VB Paul Watkins Excel Discussion (Misc queries) 4 July 21st 05 03:55 PM
Excel conversion microsoft[_3_] Excel Programming 1 August 27th 03 01:49 AM


All times are GMT +1. The time now is 08:38 AM.

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

About Us

"It's about Microsoft Excel"