Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Urgent Help with Excel (Excel 2003)

    Hi there,

    I would be grateful to anybody who can help me urgently. I need to prepare a Excel file from word file by copying data from word to Excel.

    there are multiple lines in the Word document file which need to be converted into multiple rows in Excel.

    Example :

    This is line 1
    This is line 2
    This is line 3

    How can I convert this text in word document to multiple rows in Excel. A quick reply can only save me since its aa huge data. Thanks in advance. My email is sha_8@yahoo.com

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Need Urgent Help with Excel (Excel 2003)

    Lines separated by paragraph ends (Enter) or line breaks (Shift+Enter) in Word will automatically end up in separate rows when you copy/paste from Word to Excel.

    Note: we can't handle requests to reply by e-mail (see <!rule=10>Rule 10<!/rule>).

  3. #3
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need Urgent Help with Excel (Excel 2003)

    Good morning

    This is not my code, this is something I picked up when surfing and stored it (but have never tried it),

    Copying Word to Excel

    Sub CopyTable2Excel()
    Dim oExcel As Object Excel.Application
    Dim oBook As Object Excel.Workbook
    Dim oSht As Object Excel.Worksheet
    Dim oTbl As Table
    Dim oSelect As Selection
    Dim lCols As Long
    Dim lRows As Long
    Dim sValue As String

    check for selection of the table first
    If Not Selection.Information(wdWithInTable) Then
    MsgBox Select the table first ! , vbInformation, TheWordExpert.com
    Exit Sub
    End If

    get reference to excel
    Set oExcel = CreateObject( Excel.Application )
    create new book
    Set oBook = oExcel.Workbooks.Add
    create new sheet
    Set oSht = oBook.Sheets.Add
    make excel visible
    oExcel.Visible = True

    get reference to first selected table
    Set oTbl = Selection.Tables(1)
    and to selection
    Set oSelect = Selection

    lRows = 1
    With oTbl
    Do While lRows <= .Rows.Count
    lCols = 1
    Do While lCols <= .Columns.Count
    oTbl.Cell(lRows, lCols).Select
    sValue = Selection.Text
    filter on chr(13) and more
    sValue = Left(sValue, InStr(sValue, Chr(13)) - 1)
    oSht.Cells(lRows, lCols).Value = sValue
    lCols = lCols + 1
    Loop
    lRows = lRows + 1
    Loop
    End With

    restore original selection
    oSelect.Select

    destroy all references and free memory
    Set oSelect = Nothing
    Set oTbl = Nothing
    Set oSht = Nothing
    Set oBook = Nothing
    Set oExcel = Nothing

    End Sub

    The tag with the code said RoverM

    Hope this helps

    Cheers

    Steve
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

Posting Permissions

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