Share via

The OpenDataSource method or property is not available because a macro is currently running

Anonymous
2023-01-03T11:16:53+00:00

Since the introduction of Word version 2211, I've had a problem with a VB.NET application that generates a data set (DAT file) and automatically merges with Word templates. I see the Word object open (with "Viewing" showing in the top right) but then closes throwing back the error

"The OpenDataSource method or property is not available because a macro is currently running."

It appears to relate to the new "Editing", "Reviewing" and "Viewing" options introduced in Word. The application uses the Microsoft interop to interact with the Word object and I believe the code it fails on is "MailMerge.OpenDataSource".

Rolling back the version to 2209 resolves the issue, so it definitely relates to functionality introduced in 2211 onwards. I've also tried in the beta channel for 2301 but that also has the same issue.

It seems that when it opens the template file, it defaults to opening in "Viewing" mode and I guess this is what is preventing the mail merge? Are there any options to prevent a document opening in "Viewing" mode? It's all done programmatically, so not sure if it would require development work on the application or if a setting can be changed in Word.

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

30 answers

Sort by: Most helpful
  1. Anonymous
    2023-01-14T08:56:33+00:00

    Glad the rollback has helped for now Benjamin. I’m still working to find a solution as customers understandably want to update to the latest versions.

    We do have one user on 2211 who it seems to work ok for, so the feeling is that there must be a profile related setting/registry key that would help work around the issue.

    I’m trying to get access to our Gold partnership support account, so that I can raise a ticket directly. I’ll keep you updated with any progress.

    Was this answer helpful?

    3 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-02-07T15:38:39+00:00

    I was getting the same error on a VBA application I work with. I tracked it down to opening the document as ReadOnly (I think the default option for ReadOnly is true). When you do that there is a popup message that says "You can only view this document. You do not have permissions to edit it." that is stopping the MailMerge.OpenDataSource from working properly. And since we are also opening the document as hidden to do the merge programmatically there is no way for the user to click the Ok button to continue.

    So I just changed the below code to open the document from something like:

    Word.Documents.Open(FilePath, False, True, False, , , , , , , , False)

    To this where the ReadOnly is set to False:

    Word.Documents.Open(FilePath, False, False, False, , , , , , , , False)

    That seemed to resolve it for me, and since we do a SaveAs to copy the word file and aren't editing the template anyway opening in Edit mode didn't cause any problem for me. Hopefully this will help someone else with the same issue.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2023-01-27T15:39:58+00:00

    Hi Ben, no update just yet I’m afraid but I’m aware this is affecting more and more people. I’m currently trying to get hold of our corporate support account so will update further as soon as I have any more info.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  4. Anonymous
    2023-01-25T22:29:11+00:00

    We’re still no further forward with finding a resolution. I’ve not been able to find a consistent pattern and some of our users license their Office users through their Microsoft account, so we’re unable to get them to logout.

    I’m still hoping to get at a corporate subscription to log it directly with Microsoft support team.

    I will report back as soon as I make any progress.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  5. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2023-01-03T13:02:25+00:00

    Where is the document located? When you use the term "template file" I assume that you are talking about the mail merge main document and not an actual template (.dotx or .dotm). I would probably be better to save the document as a .dotx template and have your code use Document.Add to create a new document from the template.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments