Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Microsoft.Office.Interop.Excel Texttocolumns C#

I am new to C# and I am trying to convert this vba code to C#:

Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False,
FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1),
Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11,
1), Array(12, 1), Array(13, 1 _
), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1),
Array(18, 1)), _
TrailingMinusNumbers:=True

I come up with this:

aRange = excelWorksheet.get_Range("A1",
Missing.Value);
aRange.TextToColumns("A1",
Excel.XlTextParsingType.xlDelimited,
Excel.XlTextQualifier.xlTextQualifierDoubleQuote,
false, false, false, true, false, false,
false, false, false, false, true);

I get an error with the range. I can find several vb examples of this
but no c# using the interop.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Microsoft.Office.Interop.Excel Texttocolumns C#

get_Range returns an object so you should probably cast it to Excel.Range

Excel.Range aRange = (Excel.Range)excelWorksheet.get_Range ("A:A",
Missing.Value);

But I think you should post this question to some other group (C#?).


--
urkec


"Cheryl" wrote:

I am new to C# and I am trying to convert this vba code to C#:

Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
Tab:=False, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False,
FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1),
Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11,
1), Array(12, 1), Array(13, 1 _
), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1),
Array(18, 1)), _
TrailingMinusNumbers:=True

I come up with this:

aRange = excelWorksheet.get_Range("A1",
Missing.Value);
aRange.TextToColumns("A1",
Excel.XlTextParsingType.xlDelimited,
Excel.XlTextQualifier.xlTextQualifierDoubleQuote,
false, false, false, true, false, false,
false, false, false, false, true);

I get an error with the range. I can find several vb examples of this
but no c# using the interop.

Thanks


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
Microsoft.Office.Interop.Excel when exporting from another program Colin Excel Discussion (Misc queries) 0 January 2nd 09 06:08 AM
Where can I find Microsoft.Office.Interop.Excel.dll? Fred Abrahamian Excel Programming 1 December 17th 06 10:52 PM
COMException With Microsoft.Office.Interop.Excel frankvfox Excel Programming 4 September 27th 06 04:36 PM
Microsoft.Office.Interop.Excel SaveAs error when clicking no or ca NeedsExcelAssistance Excel Programming 0 July 14th 06 02:50 PM
Exception from HRESULT: 0x800A03EC. at Microsoft.Office.Interop.Excel.WorkbookClass.get_VBProject() [email protected] Excel Programming 0 April 11th 06 04:40 PM


All times are GMT +1. The time now is 07:26 PM.

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"