![]()  | 
	
| 
		 
			 
			#1  
			 
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
			
			 
			
			HI, 
		
		
		
		
		
		
		
		
	
	i have a table with 1 row and 3 column Like this [#Des2] [#Prz] [#Imp] This macro return the error "run-time error 4605" "Command not available" If i continue the macro ends correctly Code: 
	Sub Macro4()
    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.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.Copy
    Selection.MoveDown Unit:=wdLine, Count:=1
    Selection.PasteAppendTable
End Sub
Regards Marzio  | 
| 
		 
			 
			#2  
			 
			
			
			
			
		 
		
	 | 
||||
		
		
  | 
||||
| 
		
	
		
		
			
			 
			
			Try: 
		
		
		
		
Code: 
	Sub Demo()
With Selection
  With .Find
    .ClearFormatting
    .Text = "[#Des2]"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  If .Find.Found = True Then
    If .Information(wdWithInTable) = True Then
      .MoveEnd Unit:=wdRow, Count:=1
      .Copy
      .Collapse wdCollapseEnd
      .PasteAppendTable
    End If
  End If
End With
End Sub
PS: I can't see the point of your '.Replacement.Text = "1998-11-27"' as nothing gets replaced. 
				__________________ 
		
		
		
		
		
	
	Cheers, Paul Edstein [Fmr MS MVP - Word]  | 
| 
		 
			 
			#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  | 
| 
		 
			 
			#4  
			 
			
			
			
			
		 
		
	 | 
||||
		
		
  | 
||||
| 
		
	
		
		
			
			 
			
			Your substitute code is quite unlike the code I supplied. Do you get an error with the code I supplied? If so, that suggests your Office 2016 installation is faulty, so you should try repairing it (via Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change > Repair).
		 
		
		
		
		
				__________________ 
		
		
		
		
		
	
	Cheers, Paul Edstein [Fmr MS MVP - Word]  | 
| 
		 
			 
			#5  
			 
			
			
			
			
		 
		
	 | 
||||
		
		
  | 
||||
| 
		
	
		
		
			
			 
			
			Cross-posted - without acknowledgement of the help already given here - at: https://social.msdn.microsoft.com/Fo...?forum=worddev 
		
		
		
		
		
		
			Likewise cross-posted at: https://answers.microsoft.com/en-us/...=1548836630685 For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184 
				__________________ 
		
		
		
		
		
	
	Cheers, Paul Edstein [Fmr MS MVP - Word]  | 
| 
		 
			 
			#6  
			 
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
			
			 
			
			He Paul, 
		
		
		
		
		
		
		
		
	
	yes i have the error even with your code. I have the error in different installations of word 2016 also on different servers and LAN and in new installations of word 2016. Regards Marzio  | 
| 
		 
			 
			#7  
			 
			
			
			
			
		 
		
	 | 
||||
		
		
  | 
||||
| 
		
	
		
		
			
			 
			
			In that case try: 
		
		
		
		
Code: 
	Sub Demo()
Dim Rng As Range
With Selection
  With .Find
    .ClearFormatting
    .Text = "[#Des2]"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  If .Find.Found = True Then
    If .Information(wdWithInTable) = True Then
      .MoveEnd Unit:=wdRow, Count:=1
      Set Rng = .Range
      .Collapse wdCollapseEnd
      .FormattedText = Rng.FormattedText
    End If
  End If
End With
End Sub
				__________________ 
		
		
		
		
		
	
	Cheers, Paul Edstein [Fmr MS MVP - Word]  | 
| 
		 
			 
			#8  
			 
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
			
			 
			
			Hi Paul, 
		
		
		
			I always have the same error in .PasteAppendTable even with your code. Here is the zip file that contains the word file with the problem and the text file for compilation Regards Marzio  | 
| 
		 
			 
			#9  
			 
			
			
			
			
		 
		
	 | 
||||
		
		
  | 
||||
| 
		
	
		
		
			
			 
			
			Aside from the fact the code in post #7 doesn't use .PasteAppendTable, your code works OK for me. Your code is very inefficient (e.g. nothing need ever be selected) and cluttered, though. For example, all of: 
		
		
		
		
		
		
			Code: 
	    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
                ActiveWindow.ActivePane.View.Type = wdPageView
            Else
                ActiveWindow.View.Type = wdPageView
            End If
            
            ActiveDocument.Save
            
            Selection.HomeKey Unit:=wdStory
            Application.ScreenUpdating = True
            If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
                ActiveWindow.Panes(2).Close
            End If
            If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
                ActivePane.View.Type = wdOutlineView Then
                ActiveWindow.ActivePane.View.Type = wdPrintView
            End If
            ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
            ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
'            Selection.WholeStory
'    Selection.Font.Name = "Tahoma"
'    Selection.Font.Size = 10
    ActiveWindow.ActivePane.VerticalPercentScrolled = 0
    ActiveDocument.Save
     ActiveDocument.SaveAs FileName:=UsPath + "\OffSwrm.doc", FileFormat:= _
            wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
            True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
            False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
            SaveAsAOCELetter:=False
        ActiveDocument.ExportAsFixedFormat OutputFileName:= _
        UsPath + "\OffSwrm.pdf", ExportFormat:=wdExportFormatPDF, _
        OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
        wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _
        IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _
        wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _
        True, UseISO19005_1:=False
Code: 
	ActiveDocument.SaveAs2 FileName:=UsPath + "\OffSwrm.doc", FileFormat:=wdFormatDocument, AddToRecentFiles:=False ActiveDocument.SaveAs2 FileName:=UsPath + "\OffSwrm.pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False Code: 
	 If ActiveWindow.View.SplitSpecial = wdPaneNone Then
'        ActiveWindow.ActivePane.View.Type = wdNormalView
    Else
'        ActiveWindow.View.Type = wdNormalView
    End If
				__________________ 
		
		
		
		
		
	
	Cheers, Paul Edstein [Fmr MS MVP - Word]  | 
| 
		 
			 
			#10  
			 
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
			
			 
			
			Hi Paul, 
		
		
		
		
thanks a lot, I'm sorry for my mistakes, your code in post #7 it works, i'm very happy. I also appreciated your suggestions. Can you tell me how I can to avoid that when I open the saved file OffSwrm.doc word ask me to activate the macros? PS Remember that the .PasteAppendTable dont work only with word 2016 Regards Marzio  | 
| 
		 
			 
			#11  
			 
			
			
			
			
		 
		
	 | 
||||
		
		
  | 
||||
| 
		
	
		
		
			
			 Quote: 
	
 No-one in any of your cross-posts seems to agree with you. Maybe you have a faulty Office installation. Try repairing it. 
				__________________ 
		
		
		
		
		
	
	Cheers, Paul Edstein [Fmr MS MVP - Word]  | 
| 
		 
			 
			#12  
			 
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
			
			 Quote: 
	
 Quote: 
	
 Marzio  | 
| 
		 
			 
			#13  
			 
			
			
			
			
		 
		
	 | 
||||
		
		
  | 
||||
| 
		
	
		
		
			
			 
			
			That might only mean your IT department's disk image being used for that is faulty. Hence multiple installations have the same fault...
		 
		
		
		
		
				__________________ 
		
		
		
		
		
	
	Cheers, Paul Edstein [Fmr MS MVP - Word]  | 
| 
		 
			 
			#14  
			 
			
			
			
			
		 
		
	 | 
|||
		
		
  | 
|||
| 
		
	
		
		
			
			 
			
			Hi Paul, 
		
		
		
		
		
		
		
		
	
	they are independent installations made directly by my clients on their computers in remote side. Marzio  | 
| 
		 
			 
			#15  
			 
			
			
			
			
		 
		
	 | 
||||
		
		
  | 
||||
| 
		
	
		
		
			
			 
			
			Well, if no-one is prepared to try repairing them, it's impossible to know what's going on. Another possibility is a faulty Word addin.
		 
		
		
		
		
		
		
			
				__________________ 
		
		
		
		
		
	
	Cheers, Paul Edstein [Fmr MS MVP - Word]  | 
 
 | 
	
	
| 
		 | 
			 
			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 |