Results 1 to 4 of 4

Thread: txt to excel

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Location
    Portugal
    Posts
    103

    txt to excel

    Can someone tell me if is possible to transpose the data in a text box to excel form example:

    0.0 0.0 0.0 0.0 0.0 0.0 0.0 30.4 0 0 c2t6d0
    1.1 0.1 7.5 1.6 0.0 0.0 0.9 6.1 0 0 c0t4d0
    1.1 0.1 7.5 1.6 0.0 0.0 0.9 6.0 0 0 c0t5d0

    excel:

    kw/s wait actv wsvc_t asvc_t %w %b device
    0.0 0.0 0.0 0.0 30,4 0 0 c2t6d0
    1.6 0.0 0.0 0.9 6,1 0 0 c0t4d0
    1.6 0.0 0.0 0.9 6,1 0 0 c0t5d0

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Try this...

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim xlapp As New Excel.Application
    3. Dim xlwkbook As New Excel.Workbook
    4.  
    5. Set xlapp = CreateObject("Excel.application")
    6. 'Note:  This spreadsheet must exist prior to running this code
    7. Set xlwkbook = xlapp.Workbooks.Open(App.Path & "Book1.xls")
    8. xlapp.Visible = True
    9.  
    10.     With xlapp.ActiveSheet.QueryTables.Add(Connection:= _
    11.         "TEXT;c:\windows\temp\virus.txt", Destination:=Range("A1"))
    12.         .Name = "update popup dont show"
    13.         .FieldNames = True
    14.         .RowNumbers = False
    15.         .FillAdjacentFormulas = False
    16.         .PreserveFormatting = True
    17.         .RefreshOnFileOpen = False
    18.         .RefreshStyle = xlInsertDeleteCells
    19.         .SavePassword = False
    20.         .SaveData = True
    21.         .AdjustColumnWidth = True
    22.         .RefreshPeriod = 0
    23.         .TextFilePromptOnRefresh = False
    24.         .TextFilePlatform = xlWindows
    25.         .TextFileStartRow = 1
    26.         .TextFileParseType = xlFixedWidth
    27.         .TextFileTextQualifier = xlTextQualifierDoubleQuote
    28.         .TextFileConsecutiveDelimiter = False
    29.         .TextFileTabDelimiter = True
    30.         .TextFileSemicolonDelimiter = False
    31.         .TextFileCommaDelimiter = False
    32.         .TextFileSpaceDelimiter = False
    33.         .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
    34.         .TextFileFixedColumnWidths = Array(22, 4, 3, 2, 2, 2)
    35.         .Refresh BackgroundQuery:=False
    36.     End With
    37.  
    38. xlwkbook.SaveAs ("Test.xls")
    39. xlwkbook.Close
    40.  
    41. Set xlapp = Nothing
    42.  
    43. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Location
    Portugal
    Posts
    103
    Sorry i can get the code to work, an error occurs
    in this part of the code
    /
    With xlapp.ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;c:\windows\temp\virus.txt", Destination:=Range("A1"))
    /

    "Application-defined or object-defined error"

    I don´t know why this error occurs

  4. #4
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    here's a tutorial project on how to stuff data into an excel sheet. If you're looking for a canned procedure, this isn't it. If you're looking to learn how to do office automation with excel, this is it.
    Attached Files Attached Files

Posting Permissions

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



Click Here to Expand Forum to Full Width