Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2012, 09:26 AM
jeffcoleky jeffcoleky is offline Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Windows 7 64bit Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Office 2010 32bit
Novice
Macro: Exporting Data to a LEGIBLE Excel Spreadsheet
 
Join Date: May 2012
Posts: 4
jeffcoleky is on a distinguished road
Question Macro: Exporting Data to a LEGIBLE Excel Spreadsheet

** Warning: I am a Newbie without programming experience **

I am regularly sent documents like the word document attached: "04172012 Results.docx". My job is to copy and paste each line in the word doc into the attached excel spreadsheet: "04172012 Results Copied.xlsx"

However, i KNOW there's a better way than this. I've tried to search/replace the spaces with various characters, then saving it as a text doc, and lastly then importing it into excel, but I just can't get the right combination of characters to make it work.

If someone can help me figure out how to get this done in such a way that I can automate, I would be very grateful. Your help for this will save me 30-60 minutes every time i have to do it.

I would prefer some sort of macro but being told the steps to do it manually (aside from copy and paste) would be super.



Thanks so much!! -Jeff
Attached Files
File Type: xlsx 04172012 Results Copied.xlsx (92.3 KB, 17 views)
File Type: docx 04172012 Results.docx (37.2 KB, 18 views)
Reply With Quote
  #2  
Old 05-07-2012, 12:16 PM
Charles Kenyon Charles Kenyon is offline Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Windows Vista Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,138
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

This page of Graham Mayor's may be a place to start.
http://www.gmayor.com/ExtractDataFromForms.htm
Reply With Quote
  #3  
Old 05-07-2012, 12:59 PM
jeffcoleky jeffcoleky is offline Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Windows 7 64bit Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Office 2010 32bit
Novice
Macro: Exporting Data to a LEGIBLE Excel Spreadsheet
 
Join Date: May 2012
Posts: 4
jeffcoleky is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
This page of Graham Mayor's may be a place to start.
http://www.gmayor.com/ExtractDataFromForms.htm
That's for files with form fields, not raw data.
Quote:
The macros in the first part of this page are all concerned with legacy form fields, as used in Word 2002/3 and available from Word 2007/2010's Developer ribbon tab. However it is possible to extract the data from the new Word 2007/2010 content controls and I have included a macro to do that at the end of this page.
Reply With Quote
  #4  
Old 05-07-2012, 02:27 PM
jeffcoleky jeffcoleky is offline Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Windows 7 64bit Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Office 2010 32bit
Novice
Macro: Exporting Data to a LEGIBLE Excel Spreadsheet
 
Join Date: May 2012
Posts: 4
jeffcoleky is on a distinguished road
Default

This worked (got help from another website

Code:
Sub Export2XL()
    Dim app As Object
    Dim wbk As Object
    Dim wsh As Object
    Dim r As Long
    Dim p As Long
    Dim n As Long
    Dim i As Long
    Dim arr As Variant
    Dim strLine As String
    ' Start Excel
    On Error Resume Next
    Set app = GetObject(Class:="Excel.Application")
    If app Is Nothing Then
        Set app = CreateObject(Class:="Excel.Application")
        If app Is Nothing Then
            MsgBox "Can't start Excel!", vbExclamation
            Exit Sub
        End If
    End If
    On Error GoTo ErrHandler
    ' Create workbook with one worksheet
    app.ScreenUpdating = False
    Set wbk = app.Workbooks.Add(Template:=-4167) ' xlWBATWorksheet
    Set wsh = wbk.Worksheets(1)
    r = 1
    wsh.Cells(r, 1) = "PTF"
    wsh.Cells(r, 2) = "DEF"
    wsh.Cells(r, 3) = "PURCHASER"
    wsh.Cells(r, 4) = "ADDRESS"
    wsh.Cells(r, 5) = "AMOUNT"
    ' Date
    strLine = ActiveDocument.Paragraphs(1).Range.Text
    p = InStr(strLine, vbTab)
    strLine = Mid(strLine, p + 1, Len(strLine) - p)
    wsh.Name = strLine
    ' Loop
    n = ActiveDocument.Paragraphs.Count
    For i = 2 To n
        strLine = ActiveDocument.Paragraphs(i).Range.Text
        strLine = Left(strLine, Len(strLine) - 1)
        arr = Split(strLine, vbTab)
        ' Determine type
        If arr(2) = "PTF" Then
            r = r + 1
            wsh.Cells(r, 1) = arr(3)
        ElseIf arr(1) = "DEF" Then
            wsh.Cells(r, 2) = arr(2)
        ElseIf arr(1) = "COUNT" And UBound(arr) >= 3 Then
            wsh.Cells(r, 3) = arr(3)
        ElseIf arr(1) = "ADDRESS" Then
            wsh.Cells(r, 4) = arr(2)
            wsh.Cells(r, 5) = arr(4)
        Else
            ' Footer - ignore
        End If
    Next i
ExitHandler:
    If Not app Is Nothing Then
        wsh.Range("A1:E1").EntireColumn.AutoFit
        app.ScreenUpdating = True
        app.Visible = True
    End If
    Exit Sub
ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
End Sub
Reply With Quote
  #5  
Old 05-07-2012, 03:36 PM
macropod's Avatar
macropod macropod is offline Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Windows 7 64bit Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Since you've evidently cross-posted your query at another forum, please provide a link. For cross-posting etiquette, please also read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 05-07-2012, 05:48 PM
macropod's Avatar
macropod macropod is offline Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Windows 7 64bit Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: http://social.technet.microsoft.com/...e-305ef48e7ff4
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 05-08-2012, 08:24 AM
jeffcoleky jeffcoleky is offline Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Windows 7 64bit Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Office 2010 32bit
Novice
Macro: Exporting Data to a LEGIBLE Excel Spreadsheet
 
Join Date: May 2012
Posts: 4
jeffcoleky is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Sorry about the cross posting. Thanks for your patience.
Reply With Quote
Reply

Tags
exporting to exel



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro: Exporting Data to a LEGIBLE Excel Spreadsheet * Exporting Access Data to Excel djreyrey Excel Programming 1 03-23-2012 10:03 PM
Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Importing data from excel using a macro soma104 Word 1 04-14-2011 05:10 PM
Exporting Timline Milstone Data OTPM Project 0 04-06-2011 02:34 AM
Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Exporting PST data metfuel Outlook 2 01-19-2011 04:46 PM
Macro: Exporting Data to a LEGIBLE Excel Spreadsheet Exporting data dsmithers Outlook 2 06-24-2009 09:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft