A family of Microsoft word processing software products for creating web, email, and print documents.
Somewhere along the way, Word solved this problem by itself.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Windows 10 Pro Version 1511 OS Build 10586.164
Office 365 Version 16.0.6741.2017
This problem showed up when I used code written for Word 2003. I hadn't used it since switching to Office 365. When I did run it, it would not work. This much simpler code demonstrates the problem.
Sub Test_Paste()
Dim doc As Document
Set doc = ActiveDocument
With Selection
.Copy
.Collapse Direction:=wdCollapseEnd
.TypeParagraph
.Paste
End With
End Sub
When I run it, I get this error:
Run-time error "4605"
This command is not available.
and it selects ".Paste"
Any help would be greatly appreciated.
A family of Microsoft word processing software products for creating web, email, and print documents.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Somewhere along the way, Word solved this problem by itself.
I have no issues here with your original code in the 6741.2017 or now 6741.2021 version of Office.
Perhaps there is an Add-in on your system that is causing the problem.
The purpose of the original script was to strip the text, which also had manually applied formatting , of a paragraph that was a Heading 1,or 2, or etc style, so that the paragraph could be set to Normal style and the text pasted back in with the manually applied formatting, but with the same indentation. I selected multiple paragraphs of a document, so even paragraphs that were not a Heading style were included. The manipulation had to be done paragraph by paragraph--two arrays were used--and it worked just fine when .Paste worked.
The Range object won't work because even though the paragraph of the Heading is removed from the selection, the Range object is formatted as a Heading. When it is inserted, it is inserted as a Heading.
The real solution is to get .Paste fixed--get Word fixed--because I can't use .Paste in any script.
I tried using the Repair option for 365, but each time it failed because, it said, there was an installation in process. Even after two restarts after Office was totally, according to the installer, reinstalled.
I am not sure of how to proceed from here.
Bill Martz
Use:
ActiveDocument.Bookmarks.Add "temp", Selection.Range
Selection.Range.InsertAfter vbCr
Selection.Collapse wdCollapseEnd
Selection.FormattedText = ActiveDocument.Bookmarks("temp").Range.FormattedText
ActiveDocument.Bookmarks("temp").Delete