Hi,
I have a word document with a table with 1 row and 3 columns,
[#Des2] | [#Prz2] | [#Imp2] |
with tags in the cells, that I want to replace with data read from a text file. When I run the macro the system returns the error Run-Time error 4605 command not available at Selection.PasteAppendTable, if I access the debug and press F5 the macro ends regularly.
If I run the macro step by step it's all OK.
The error is only with word 2016, with the other version everything is OK.
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
Thanks for help
Marzio