Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-26-2019, 01:46 PM
Marzio Marzio is offline run-time error 4605 command not available with Selection.paste Windows 10 run-time error 4605 command not available with Selection.paste Office 2016
Novice
run-time error 4605 command not available with Selection.paste
 
Join Date: Jan 2019
Posts: 7
Marzio is on a distinguished road
Default run-time error 4605 command not available with Selection.paste

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
The error happens only with word 2016 with other version is all OK



Regards

Marzio
Reply With Quote
  #2  
Old 01-26-2019, 10:59 PM
macropod's Avatar
macropod macropod is offline run-time error 4605 command not available with Selection.paste Windows 7 64bit run-time error 4605 command not available with Selection.paste Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
Note the inclusion of error-checking.

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]
Reply With Quote
  #3  
Old 01-28-2019, 12:02 AM
Marzio Marzio is offline run-time error 4605 command not available with Selection.paste Windows 10 run-time error 4605 command not available with Selection.paste Office 2016
Novice
run-time error 4605 command not available with Selection.paste
 
Join Date: Jan 2019
Posts: 7
Marzio is on a distinguished road
Default

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
here the file with the macro 2 with what I would like to get

Regards
Marzio
Reply With Quote
  #4  
Old 01-28-2019, 03:35 AM
macropod's Avatar
macropod macropod is offline run-time error 4605 command not available with Selection.paste Windows 7 64bit run-time error 4605 command not available with Selection.paste Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 01-28-2019, 03:44 AM
macropod's Avatar
macropod macropod is offline run-time error 4605 command not available with Selection.paste Windows 7 64bit run-time error 4605 command not available with Selection.paste Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #6  
Old 01-28-2019, 04:27 AM
Marzio Marzio is offline run-time error 4605 command not available with Selection.paste Windows 10 run-time error 4605 command not available with Selection.paste Office 2016
Novice
run-time error 4605 command not available with Selection.paste
 
Join Date: Jan 2019
Posts: 7
Marzio is on a distinguished road
Default

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
Reply With Quote
  #7  
Old 01-28-2019, 12:46 PM
macropod's Avatar
macropod macropod is offline run-time error 4605 command not available with Selection.paste Windows 7 64bit run-time error 4605 command not available with Selection.paste Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #8  
Old 01-29-2019, 10:34 AM
Marzio Marzio is offline run-time error 4605 command not available with Selection.paste Windows 10 run-time error 4605 command not available with Selection.paste Office 2016
Novice
run-time error 4605 command not available with Selection.paste
 
Join Date: Jan 2019
Posts: 7
Marzio is on a distinguished road
Default

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
Attached Files
File Type: zip Test.zip (48.3 KB, 9 views)
Reply With Quote
  #9  
Old 01-29-2019, 01:32 PM
macropod's Avatar
macropod macropod is offline run-time error 4605 command not available with Selection.paste Windows 7 64bit run-time error 4605 command not available with Selection.paste Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
could be reduced to:
Code:
ActiveDocument.SaveAs2 FileName:=UsPath + "\OffSwrm.doc", FileFormat:=wdFormatDocument, AddToRecentFiles:=False
ActiveDocument.SaveAs2 FileName:=UsPath + "\OffSwrm.pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False
Likewise, you can do away with:
Code:
 If ActiveWindow.View.SplitSpecial = wdPaneNone Then
'        ActiveWindow.ActivePane.View.Type = wdNormalView
    Else
'        ActiveWindow.View.Type = wdNormalView
    End If
You should also declare all your variables - and only define those you actually use.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 01-30-2019, 01:29 AM
Marzio Marzio is offline run-time error 4605 command not available with Selection.paste Windows 10 run-time error 4605 command not available with Selection.paste Office 2016
Novice
run-time error 4605 command not available with Selection.paste
 
Join Date: Jan 2019
Posts: 7
Marzio is on a distinguished road
Default

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
Reply With Quote
  #11  
Old 01-30-2019, 01:37 AM
macropod's Avatar
macropod macropod is offline run-time error 4605 command not available with Selection.paste Windows 7 64bit run-time error 4605 command not available with Selection.paste Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Marzio View Post
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?
Check your macro security settings - they may be too high. Alternatively, save the document to a trusted location of make the current location a trusted one.
Quote:
Originally Posted by Marzio View Post
Remember that the .PasteAppendTable dont work only with word 2016
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]
Reply With Quote
  #12  
Old 01-30-2019, 01:46 AM
Marzio Marzio is offline run-time error 4605 command not available with Selection.paste Windows 10 run-time error 4605 command not available with Selection.paste Office 2016
Novice
run-time error 4605 command not available with Selection.paste
 
Join Date: Jan 2019
Posts: 7
Marzio is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Check your macro security settings - they may be too high. Alternatively, save the document to a trusted location of make the current location a trusted one.
I would like OffSwrm.doc to be saved without macros because it is already compiled, when it is reopened it does not have to run the macro and therefore does not require execution

Quote:
No-one in any of your cross-posts seems to agree with you. Maybe you have a faulty Office installation. Try repairing it.
The problem is in different installations on different lan and also on new office installations

Marzio
Reply With Quote
  #13  
Old 01-30-2019, 01:55 AM
macropod's Avatar
macropod macropod is offline run-time error 4605 command not available with Selection.paste Windows 7 64bit run-time error 4605 command not available with Selection.paste Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Marzio View Post
The problem is in different installations on different lan and also on new office installations
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]
Reply With Quote
  #14  
Old 01-30-2019, 04:05 AM
Marzio Marzio is offline run-time error 4605 command not available with Selection.paste Windows 10 run-time error 4605 command not available with Selection.paste Office 2016
Novice
run-time error 4605 command not available with Selection.paste
 
Join Date: Jan 2019
Posts: 7
Marzio is on a distinguished road
Default

Hi Paul,
they are independent installations made directly by my clients on their computers in remote side.

Marzio
Reply With Quote
  #15  
Old 01-30-2019, 04:46 AM
macropod's Avatar
macropod macropod is offline run-time error 4605 command not available with Selection.paste Windows 7 64bit run-time error 4605 command not available with Selection.paste Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



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
run-time error 4605 command not available with Selection.paste Error 4605 when looping through files in folder and deleting comments Peterson Word VBA 2 04-19-2018 08:45 AM
run-time error 4605 command not available with Selection.paste 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
run-time error 4605 command not available with Selection.paste Edit Links Command Selection nkg Word 1 02-19-2012 07:21 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft