![]() |
|
#3
|
|||
|
|||
|
Hi Paul,
even with your code I always have the error After copying the row, I replace the tags if the Selection.PasteAppenTable statement passes everything works. When I have the error, with debug I say to continue the macro continues regularly and adds as many lines I want without giving more error. If I run the macro step all is well. macro with an example of substitution Code:
Sub Macro2()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "[#Des2]"
.Replacement.Text = "1998-11-27"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.SelectRow
Selection.Copy
Do While I < 10
I = I + 1
Code = "Code_" & I
Prz = "Prz_" & I
Import = "Import_" & I
X = 0
Do While X < 3
X = X + 1
If X = 1 Then a = "[#Des2]": Test = Code
If X = 2 Then a = "[#Prz2]": Test = Prz
If X = 3 Then a = "[#Imp2]": Test = Import
Selection.Find.ClearFormatting
With Selection.Find
.Text = a
.Replacement.Text = Test
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceOne
Loop
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.PasteAppendTable
Loop
Selection.Find.ClearFormatting
With Selection.Find
.Text = a
.Replacement.Text = Test
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Rows.Delete
End Sub
Regards Marzio |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Word Error Message Run time Error 4605 | baes10 | Word VBA | 1 | 08-30-2018 02:37 PM |
Error 4605 when looping through files in folder and deleting comments
|
Peterson | Word VBA | 2 | 04-19-2018 08:45 AM |
Selection.Click command? or something similar?
|
mrlemmer11 | Word VBA | 1 | 07-06-2015 09:17 PM |
| PasteAppendTable not available (Run-Time Error 4605) | q_scribe | Word VBA | 1 | 08-12-2013 09:56 AM |
Edit Links Command Selection
|
nkg | Word | 1 | 02-19-2012 07:21 PM |