+ Reply to Thread
Results 1 to 2 of 2

Workbooks.OpenText Fieldinfo

  1. #1
    Registered User
    Join Date
    02-24-2007
    Posts
    1

    Workbooks.OpenText Fieldinfo

    Hi,

    Could anybody help me with this parameter FieldInfo???

    When I don't use this parameter I can import my text-file to Excel, but I want to assign my Columns to a Datatype.

    Here's my code (Visual Basic 6):


    Dim intCol(250), intDataType(250) As Integer
    Dim intArray(250, 250) As Integer
    Dim intTel As Integer

    For intTel = 0 To UBound(intCol)
    intCol(intTel) = intTel + 1
    Next intTel

    For intTel = 0 To UBound(intDataType)
    intDataType(intTel) = xlGeneralFormat
    Next intTel

    ' populate the array for fieldinfo
    For intTel = LBound(intArray) To UBound(intArray)
    intArray(intTel, 1) = intCol(intTel)
    intArray(intTel, 2) = intDataType(intTel)
    Next intTel

    If strSep = "" Then
    strSep = vbTab
    End If

    Dim objEXL As New Excel.Application


    If objEXL Is Nothing Then
    MsgBox ("Couldn't start Excel")
    Exit Function
    Else
    On Error GoTo EndMacro:
    objEXL.Application.ScreenUpdating = False

    'Creating Workbook
    Dim objWBook As Workbook
    'Create a new spreadsheet
    Set objWBook = objEXL.Workbooks.Add

    'Creating worksheet
    Dim objWSheet As New Excel.Worksheet

    'Adding new worksheet to excel workbooks
    Set objWSheet = objEXL.ActiveSheet


    objEXL.Workbooks.OpenText FileName:=strImportFilePath, Origin:=xlMSDOS, StartRow:=2, _
    Local:=True, DecimalSeparator:=",", ThousandsSeparator:=".", FieldInfo:=intArray


    Set objWBook = ActiveWorkbook

    End If
    Last edited by Peterppp; 02-24-2007 at 01:15 PM.

  2. #2
    Forum Contributor
    Join Date
    01-24-2007
    Location
    Southampton, UK
    Posts
    137
    There was a similar problem posted on this forum that I responded to....

    http://www.excelforum.com/showthread.php?t=589385

    This may help, although I can't see anything obviously wrong with your code - does it produce any particular error code or description?

+ 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