Share via

Mail Merge Run Time Error 5852 Requested Object is not Available

Uptergrove, Carolyn 0 Reputation points
2026-02-20T16:43:51.7733333+00:00

What the Code Does The Technical Breakdown To use this macro, your mail merge data source must contain specific columns for

Microsoft 365 and Office | Word | For business | Windows

3 answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323K Reputation points MVP Volunteer Moderator
    2026-02-21T21:26:30.0366667+00:00

    The second row of the data source is almost certainly empty.

    If you remove that and any immediately subsequent empty rows, the problem should be overcome.

    Failing that, I would suggest that you contact the developer of that method, or use my MergeTools Add-in, for which I provide full support, and which can be downloaded from https://mergetoolsaddin.com/

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments

  2. Anonymous
    2026-02-20T18:44:05.89+00:00

    Hi @Uptergrove, Carolyn,

    Thank you for posting your question in the Microsoft Q&A forum and for sharing the details and screenshot, that context really helps.

    The Run-time error 5852 (“Requested object is not available”) in a Mail Merge macro typically occurs when Word tries to reference a Mail Merge object (such as the DataSource, ActiveRecord, or a specific DataField) before the data source is fully connected, or when the expected record/field is not available at that moment.

    Based on the highlighted line in your code:

    masterDoc.MailMerge.DataSource.ActiveRecord = wdLastRecord

    this error most commonly happens in a few situations:

    1/ The mail merge hasn’t been fully initialized:

    For example, if the data source wasn’t successfully linked (or the document isn’t truly in a Mail Merge “main document” state), Word won’t be able to move to the last record.

    2/ The data source is connected, but there are no available records:

    This can happen if the source file path is incorrect, the source opens without data, or Word can’t read the list as expected.

    3/ One or more fields referenced in the macro don’t exist in the data source:

    Since your macro calls fields such as:

    DataFields("PdfFolderPath")

    DataFields("PdfFileName")

    Word will throw this type of error if a field name is missing, spelled differently, or not being recognized from the source.

    4/ The wrong document is active or the document is restricted:

    In some cases, the macro is run from an output document (instead of the original merge template), or the document is protected, which can prevent Mail Merge objects from behaving normally.

    Here are a few checks to help isolate the issue:

    1/ Confirm Word recognizes this file as the Mail Merge main document:

    In Word, go to Mailings > Start Mail Merge, and make sure it’s set correctly (for example, not reset to a normal document). Then reconnect the data source and test again.

    2/ Validate the data source headers (field/column names):

    Please double‑check your spreadsheet/source file includes the exact field names used in the macro (including spelling and spacing), such as:

    • Cost-it No
    • PdfFolderPath
    • PdfFileName (and any other fields your script depends on).

    3/ Add a safeguard before jumping to the last record:

    This prevents Word from trying to move to a record when none exist:

    If masterDoc.MailMerge.DataSource.RecordCount > 0 Then

        masterDoc.MailMerge.DataSource.ActiveRecord = wdLastRecord

    End If

    4/ Make sure the merge is fully ready before referencing the output document:

    Sometimes Word needs a moment to finish creating the merged output, and referencing ActiveDocument too quickly can trigger object‑availability errors.

    You can also review the same issue with your case here: How to Fix Run-Time Error "5852".

    I hope this information helps move things forward. Please feel free to let me know how it goes, or if you need any further assistance. I’ll be happy to help.

    I look forward to your reply.


    If the answer is helpful, click on "Accept Answer" and please vote positively. If you have additional questions about this answer, click on "Comment".

    Note: Follow the steps in our documentation to enable email notifications if you want to receive the email notification related to this thread.

    Was this answer helpful?

    0 comments No comments

  3. AI answer

    2026-02-20T16:43:59.64+00:00

    The runtime error 5852 in a mail merge operation typically indicates that the requested object is not available. This can occur due to several reasons, such as:

    1. Missing Data Source: Ensure that the data source for the mail merge is correctly specified and accessible. If the data source file is missing or has been moved, the macro will fail to find it.
    2. Incorrect Field Names: The columns in your data source must match the field names used in your mail merge document. If there are discrepancies, the merge will not work properly.
    3. Document State: Ensure that the document you are attempting to merge into is open and in a state that allows for merging. If the document is closed or in a read-only state, it may lead to this error.
    4. Active Document Issues: If the document you are trying to use for the mail merge is not the active document, you may encounter this error. Make sure to activate the correct document before running the merge.

    To troubleshoot, check the above points and ensure that everything is set up correctly before running your macro again.

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.