I have a 300-page word document with some data that I have to use a macro in Word to copy and then am trying to paste into Excel. I got this to work with one copy/paste, but how do I send the focus back to the Word document, and run another macro in Word, then copy/paste back to Excel?
Here's what the text looks like, and I need to copy/paste the name, then space over and get the next number, then one of the dates, and then get the classes that have the codes 7500 and 8102, and then get the name associated with that code number.
DOE, JOHN A 9999999999 4/23/2008 8/23/2006 5/28/1992 F
412 E 18TH ST.
ANYWHERE MO 64683- 10
A 1 7500 LA 1 1ST 1 1 EV RM 21 LANG ASIEBENBORN, S.
A 2 7645 HEALTH 1ST 3 1 EV RM 201 TMS HOFFMAN, J
A 3 7485 PHY.SCIENCE 1ST 3 1 EV RM 25 SCIENCSTARK, A.
A 4 7885 AG SCI 1 1ST 3 1 EV VO-AG ROGERS, S.
A 5 7931 CITIZ & GOVT 1ST 9 1 EV RM 12 SOC STBEAVERS, C.
A 6 8102 GEOM 1ST 5 1 EV RM 15 MATH CLOUGH, R.
A 7 7691 THS SINGERS 1ST 1 1 EV VOCAL MUSIC ROBBINS E.
A 8 7752 HOMEROOM 1ST 1 1 EV RM 10 SOC STTIPTON, M.
A 1 7512 LA 1 2ND 2 1 EV RM 21 LANG ASIEBENBORN, S.
A 2 7650 LIFE SPORTS 2ND 2 1 EV GYM BEST, L.
A 3 7487 PHY.SCIENCE 2ND 4 1 EV RM 25 SCIENCSTARK, A.
A 4 7886 AG SCI 1 2ND 4 1 EV VO-AG ROGERS, S.
A 5 8024 CITIZ & GOVT 2ND 10 1 EV RM 12 SOC STBEAVERS, C.
A 6 8103 GEOM 2ND 6 1 EV RM 15 MATH CLOUGH, R.
A 7 7880 THS SINGERS 2ND 2 1 EV VOCAL MUSIC ROBBINS E.
A 8 8052 HOMEROOM 2ND 1 1 EV RM 10 SOC STTIPTON, M.
--------------------
Here's the code that I have so far, in a macro that runs out of Excel 2007 and opens Word 2007.
Sub Macro1()
'
Dim oBook As Object
Dim lNextRow As Long
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
Set oDOC = appWd.documents.Open("C:\dump\HS_sched.docx")
Set Focus = oDOC
Dim WordObj As Object
Set WordObj = CreateObject("Word.Basic")
With WordObj
.ToolsMacro Name:="Macro2", Run:=True
End With
Set WordObj = Nothing
ActiveSheet.Paste
ActiveCell.Offset(0, 1).Range("A1").Select
End Sub
-------
So how do I get the Excel macro to go back and forth from Word with the copy/pasting?
Here's what the text looks like, and I need to copy/paste the name, then space over and get the next number, then one of the dates, and then get the classes that have the codes 7500 and 8102, and then get the name associated with that code number.
DOE, JOHN A 9999999999 4/23/2008 8/23/2006 5/28/1992 F
412 E 18TH ST.
ANYWHERE MO 64683- 10
A 1 7500 LA 1 1ST 1 1 EV RM 21 LANG ASIEBENBORN, S.
A 2 7645 HEALTH 1ST 3 1 EV RM 201 TMS HOFFMAN, J
A 3 7485 PHY.SCIENCE 1ST 3 1 EV RM 25 SCIENCSTARK, A.
A 4 7885 AG SCI 1 1ST 3 1 EV VO-AG ROGERS, S.
A 5 7931 CITIZ & GOVT 1ST 9 1 EV RM 12 SOC STBEAVERS, C.
A 6 8102 GEOM 1ST 5 1 EV RM 15 MATH CLOUGH, R.
A 7 7691 THS SINGERS 1ST 1 1 EV VOCAL MUSIC ROBBINS E.
A 8 7752 HOMEROOM 1ST 1 1 EV RM 10 SOC STTIPTON, M.
A 1 7512 LA 1 2ND 2 1 EV RM 21 LANG ASIEBENBORN, S.
A 2 7650 LIFE SPORTS 2ND 2 1 EV GYM BEST, L.
A 3 7487 PHY.SCIENCE 2ND 4 1 EV RM 25 SCIENCSTARK, A.
A 4 7886 AG SCI 1 2ND 4 1 EV VO-AG ROGERS, S.
A 5 8024 CITIZ & GOVT 2ND 10 1 EV RM 12 SOC STBEAVERS, C.
A 6 8103 GEOM 2ND 6 1 EV RM 15 MATH CLOUGH, R.
A 7 7880 THS SINGERS 2ND 2 1 EV VOCAL MUSIC ROBBINS E.
A 8 8052 HOMEROOM 2ND 1 1 EV RM 10 SOC STTIPTON, M.
--------------------
Here's the code that I have so far, in a macro that runs out of Excel 2007 and opens Word 2007.
Sub Macro1()
'
Dim oBook As Object
Dim lNextRow As Long
Set appWd = CreateObject("Word.Application")
appWd.Visible = True
Set oDOC = appWd.documents.Open("C:\dump\HS_sched.docx")
Set Focus = oDOC
Dim WordObj As Object
Set WordObj = CreateObject("Word.Basic")
With WordObj
.ToolsMacro Name:="Macro2", Run:=True
End With
Set WordObj = Nothing
ActiveSheet.Paste
ActiveCell.Offset(0, 1).Range("A1").Select
End Sub
-------
So how do I get the Excel macro to go back and forth from Word with the copy/pasting?