george hart
Board Regular
- Joined
- Dec 4, 2008
- Messages
- 241
The code below Falls over here: Selection.Find.ClearFormatting. If i was to remove: it works in terms of copying the data from Excel???? Any ideas?
Selection.Find.ClearFormatting
With Selection.Find
.Text = "P/Car"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=11, Extend:=wdExtend
Selection.MoveDown Unit:=wdParagraph, Count:=21, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Dim WordApp As Object
Dim wrdDoc As Object
Dim tmpDoc As Object
Dim WDoc As String
Dim myDoc As String
myDoc = "HSS Fleet Report 0500"
WDoc = ThisWorkbook.Path & "\" & myDoc & ".doc"
Set WordApp = GetObject(, "Word.Application")
'Excel copy data
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
WordApp.Activate
Selection.Find.ClearFormatting
With Selection.Find
.Text = "P/Car"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=11, Extend:=wdExtend
Selection.MoveDown Unit:=wdParagraph, Count:=21, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
WordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteText, _
Placement:=wdInLine, DisplayAsIcon:=False
Selection.Find.ClearFormatting
With Selection.Find
.Text = "P/Car"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=11, Extend:=wdExtend
Selection.MoveDown Unit:=wdParagraph, Count:=21, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Dim WordApp As Object
Dim wrdDoc As Object
Dim tmpDoc As Object
Dim WDoc As String
Dim myDoc As String
myDoc = "HSS Fleet Report 0500"
WDoc = ThisWorkbook.Path & "\" & myDoc & ".doc"
Set WordApp = GetObject(, "Word.Application")
'Excel copy data
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
WordApp.Activate
Selection.Find.ClearFormatting
With Selection.Find
.Text = "P/Car"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=11, Extend:=wdExtend
Selection.MoveDown Unit:=wdParagraph, Count:=21, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
WordApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteText, _
Placement:=wdInLine, DisplayAsIcon:=False