Share via

Word 2016 - Runtime Error 4605

Anonymous
2017-10-18T20:29:56+00:00

When running a macro in a Word 2016 document that has 66 pages it stops at the second page and gives the Run-time error'4605':  This method or property is not available because no text is selected.  I've used this same macro for three years and never had this error before.  I use MS Outlook to do the Mail Merge. The only changes have been to upgrade from Office 2013 to Office 2016. We might have also upgraded our Citrix server, but the document itself has remained unchanged.

Sub BreakOnSection()

    'Used to set criteria for moving through the document by section.

    Application.Browser.Target = wdBrowseSection

    'A mailmerge document ends with a section break next page.

    'Subtracting one from the section count stop error message.

    For i = 1 To ((ActiveDocument.Sections.Count) - 1)

        'Select and copy the section text to the clipboard

        ActiveDocument.Bookmarks("\Section").Range.Copy

        'Create a new document to paste text from clipboard.

        Documents.Add

        Selection.Paste

        'Removes the break that is copied at the end of the section, if any.

        Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend

        Selection.Delete Unit:=wdCharacter, Count:=1

        ChangeFileOpenDirectory "\XXXX.com\data\users\hll1\Desktop\Mail Merge"

        DocNum = DocNum + 1

        ActiveDocument.SaveAs FileName:="CASIND_" & DocNum & ".doc"

        ActiveDocument.Close

        'Move the selection to the next section in the document

        Application.Browser.Next

    Next i

    ActiveDocument.Close savechanges:=wdDoNotSaveChanges

End Sub

Where have I gone wrong?

Microsoft 365 and Office | Word | For home | Windows

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.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2017-10-18T22:53:15+00:00

    Better if you declare a Range variable and set it to the .Range of the \Section bookmark and then move the end of the Range back one space so that it does not include the Section Break and then set the Range of the new document to the FormattedText of the Range variable.  The you do not have to try and manipulate the selection in the new document.

    Alternatively use the Merge to Individual documents facility on my Merge Tools Add-in that is contained in the MERGE TOOLS ADD-IN.zip file that you can download from the following page of my One Drive:

    http://bit.ly/1hduSCB

    Extract the files from the archive and read

    “READ ME – Setting up and using the Merge Tools Add-in.docx

    to see how to install and use the various tools.

    Using those tools, it is possible to perform the following types of merge that cannot be done with Mail Merge “out-of-the-box”:

    • Merge to e-mail messages either with or without attachments, with the documents created by the merge being sent as either Word or PDF attachments or as the body of the e-mail message.
    • Merge to individual documents in either Word or PDF format with the filenames being supplied by the data in one of the fields in the data source
    • Many to One type merges, which can be used for creating documents such as invoices where there are multiple records in the data source that have common data in one of the fields
    • Merging to a document that will include a chart that is unique to each record in the data source
    • Merging a document with Content Controls
    • Merging a document that contains Legacy FormFields
    • Duplex Merges
    • Merging to a printer that will collate and staple the output created from each record in the data source.

    Was this answer helpful?

    0 comments No comments