K
Keri
I used the Word "Record a Macro" function to write this code for me. I
record the macro, and it all works fine. But when I try to run the macro
again, I get "Run Time Error 4605: 'This method or property is not available
because no text is selected'". The debugger has the "Selection.Copy" line
highlighted.
What is the problem?
Here is the code:
RTM4 Macro
' Macro recorded 11/4/2005 by Keri McConnell
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "T-?{35}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Copy
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=3, _
NumRows:=100, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
End Sub
record the macro, and it all works fine. But when I try to run the macro
again, I get "Run Time Error 4605: 'This method or property is not available
because no text is selected'". The debugger has the "Selection.Copy" line
highlighted.
What is the problem?
Here is the code:
RTM4 Macro
' Macro recorded 11/4/2005 by Keri McConnell
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "T-?{35}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Copy
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=3, _
NumRows:=100, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
End Sub