M
Mikel
I am new to Word and VBA my current version is Word 97.
I have written a macro that searches a document for
specific text, when found it cuts the selection and pastes
it into a new document and saves the new document. I would
like this macro to go back to the beginning line of the
first document and do the find again until all projects
have been cut and pasted into their own document. The last
line will always have **** in it.
The macro is below.
Public Sub SelectionFind()
'Macro searchs document and selects then cuts text
'from top of document to **** then pastes it into
'another document and saves it.
Application.ScreenUpdating = False
' Turn on ExtendMode
Selection.ExtendMode = True
' Perform the search
With Selection.Find
.ClearFormatting
.Text = "****"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Execute
Selection.Expand wdLine
Selection.Cut
Documents.Add
Selection.Paste
'========================================================
'Saves and Renames New Document
'===================================================
'Show SaveAs dialog to allow user to save copy
With Dialogs(wdDialogFileSaveAs)
.Show
End With
End With
' Turn off ExtendMode
Selection.ExtendMode = False
Application.ScreenUpdating = True
End Sub
Thanks for any help you can provide,
Mikel
I have written a macro that searches a document for
specific text, when found it cuts the selection and pastes
it into a new document and saves the new document. I would
like this macro to go back to the beginning line of the
first document and do the find again until all projects
have been cut and pasted into their own document. The last
line will always have **** in it.
The macro is below.
Public Sub SelectionFind()
'Macro searchs document and selects then cuts text
'from top of document to **** then pastes it into
'another document and saves it.
Application.ScreenUpdating = False
' Turn on ExtendMode
Selection.ExtendMode = True
' Perform the search
With Selection.Find
.ClearFormatting
.Text = "****"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Execute
Selection.Expand wdLine
Selection.Cut
Documents.Add
Selection.Paste
'========================================================
'Saves and Renames New Document
'===================================================
'Show SaveAs dialog to allow user to save copy
With Dialogs(wdDialogFileSaveAs)
.Show
End With
End With
' Turn off ExtendMode
Selection.ExtendMode = False
Application.ScreenUpdating = True
End Sub
Thanks for any help you can provide,
Mikel