+ Reply to Thread
Results 1 to 3 of 3

Excel VBA to VB.NET conversion

  1. #1
    KreativeKai
    Guest

    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

  2. #2
    KreativeKai
    Guest

    RE: Excel VBA to VB.NET conversion

    I always like to follow-up even if a posting that I made is unanswered.
    Sometimes when you're looking for a programming answer on a message board and
    you find the exact problem you're having, it is disheartening when there was
    no answer posted.

    Here is the solution that I received on another message board:
    http://gotdotnet.com/Community/Messa...&Page=1#363383

    Hope someone benefits from the answer in the future.

    --
    Lost in the Vast Sea of .NET


  3. #3
    R..VENKATARAMAN
    Guest

    Re: Excel VBA to VB.NET conversion

    yes this is a recent problem in all the newsgroups. people cut off all the
    threads and post only their response; like
    "this is the brilliant solution" full stop. the brillinat solution is not
    avilable immediately. you have to go to google groups search and key in the
    subject and then you get the whole thread.


    "KreativeKai" <[email protected]> wrote in message
    news:[email protected]...
    >I always like to follow-up even if a posting that I made is unanswered.
    > Sometimes when you're looking for a programming answer on a message board
    > and
    > you find the exact problem you're having, it is disheartening when there
    > was
    > no answer posted.
    >
    > Here is the solution that I received on another message board:
    > http://gotdotnet.com/Community/Messa...&Page=1#363383
    >
    > Hope someone benefits from the answer in the future.
    >
    > --
    > Lost in the Vast Sea of .NET
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1