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-02-14T22:53:18+00:00

    Hi Tom

    I'm very happy to report that I have just applied 2302 (Build 16130.20128 - Current Channel Preview) and the issue does indeed seem to have been resolved in this version. I've now been able to generate and merge letters/documents without making any code change.

    I had managed to speak to a Microsoft engineer last Wednesday who assured me the issue was being escalated to the developers, however, I have to say I wasn't entirely sure whether he was just fobbing me off as the ticket was marked as closed shortly after. However, if the preview is anything to go by... we might be in luck!!

    I'm not sure when that's due for general release so I've not been able to test with our customers yet but this certainly looks more positive.

    Further update Tom - I’ve just found the release notes for the preview release:

    https://learn.microsoft.com/en-us/officeupdates/current-channel-preview#version-2302-february-13

    This looks like it may have been the policy we were looking for:

    • We fixed an issue where applying the blockcontentexecutionfrominternet policy would prevent files containing an embedded macro to no longer to run.

    I can’t find anything else that looks relevant in the notes so this looks the most likely item and it seems to have fixed it across various applications I have tested. A valentines gift from Microsoft perhaps ;)

    Was this answer helpful?

    6 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-02-06T22:19:12+00:00

    We were able to get around this issue by using the documents Add method instead of Open.

    Reference: https://stackoverflow.com/questions/18533198/filling-fields-in-word-using-c-sharp-and-microsoft-word-interop/18572535#18572535

    Was this answer helpful?

    4 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2023-02-06T21:38:41+00:00

    Hi Tom

    We had found in versions prior to 2211 that using templates (and merging them) from a “Trusted Location” (added into Word Trust Center) had helped with this error but since 2211, that workaround no longer resolves the issue.

    As it works on some machines, there must be a local profile setting/key but as yet, nobody has been able to find out what that is.

    I did manage to speak with a Microsoft engineer through my own Office subscription last week and he assured me this was being passed onto the developers but I’ve heard nothing since. I’m also trying to get another ticket raised through our corporate subscription but this is taking some time!

    It’s also becoming a serious problem for us with more customers updating to the latest releases. I will update as soon as I have any progress and would really appreciate the same.

    Thanks

    Was this answer helpful?

    4 people found this answer helpful.
    0 comments No comments
  4. Anonymous
    2023-01-14T00:03:29+00:00

    I also work on a .NET application that provides a dataset and a docx template to Word to perform a merge. We have just started getting reports from our users that they are getting this same "OpenDataSource method or property is not available because a macro is currently running" error. Thanks to this page I have gotten them rolled back to version 2209 and they are again able to perform these merges via our app. Definitely seems to be an issue with recent Office 365 updates.

    Was this answer helpful?

    3 people found this answer helpful.
    0 comments No comments
  5. Anonymous
    2023-01-03T14:04:18+00:00

    Thanks Doug. Yes, the template is a .doc or .docx containing template letters/forms with mergefields. The location of these is initially a network share, where we then copy into a local temp path (configurable) and merge into the data source file from here.

    I've tried adding the temp path where the merge takes place as a trusted location within Word (I've also added the original network location for good measure) but that hasn't helped.

    The problem we'll have with saving the templates as dotx is that there are hundreds (if not thousands), so is no small task to go through them prior to any code change.

    Interestingly, I have a user who has 2211 and the merge works, which seems to suggest some kind of environment/setting problem but I'm having a job tracking down what that may be and how it would relate to any new functionality in 2211.

    Was this answer helpful?

    3 people found this answer helpful.
    0 comments No comments