F
Fogharty
I'm using Word 2004. I have two documents open. Is there a way, using
macros, to go from Document 1 to Document 2, where I'll go to a
certain line and copy it, then go back to Document 1 and save it using
the text I have just copied.
I have the macro down for going to the line, copying, and saving. What
I need is the part where I go from doc to doc without regard to the
document name. So I'll be in "Active Document" first, then I need to
go to "?" (other Document) then back to "Previous Document."
So I just need the navigation part.
Here is the code for doing all this within the SAME document (finding
a 10-character line):
Sub copy_course()
' copy_course Macro
' Macro recorded 1/22/10 by Fogharty
'
Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=1,
Name:=""
Selection.Find.ClearFormatting
With Selection.Find
.Text = "??????????"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.ClearFormatting
With Selection.Find
.Text = "??????????"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Copy
Dim myName As String
Dim myPath As String
Dim docName As String
docName = InputBox("Please enter the file name for the
document.")
myPath = ActiveDocument.Path
If myPath = "" Then
myPath = Options.DefaultFilePath(wdDocumentsPath)
End If
myName = myPath & Application.PathSeparator & docName
ActiveDocument.SaveAs myName
End Sub
macros, to go from Document 1 to Document 2, where I'll go to a
certain line and copy it, then go back to Document 1 and save it using
the text I have just copied.
I have the macro down for going to the line, copying, and saving. What
I need is the part where I go from doc to doc without regard to the
document name. So I'll be in "Active Document" first, then I need to
go to "?" (other Document) then back to "Previous Document."
So I just need the navigation part.
Here is the code for doing all this within the SAME document (finding
a 10-character line):
Sub copy_course()
' copy_course Macro
' Macro recorded 1/22/10 by Fogharty
'
Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=1,
Name:=""
Selection.Find.ClearFormatting
With Selection.Find
.Text = "??????????"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.ClearFormatting
With Selection.Find
.Text = "??????????"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Copy
Dim myName As String
Dim myPath As String
Dim docName As String
docName = InputBox("Please enter the file name for the
document.")
myPath = ActiveDocument.Path
If myPath = "" Then
myPath = Options.DefaultFilePath(wdDocumentsPath)
End If
myName = myPath & Application.PathSeparator & docName
ActiveDocument.SaveAs myName
End Sub