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-07T09:36:50+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

    This workaround seems working for us as well: all internal cases seem resolved. Now we will distribute the workaround to customers who reported the problem to see if they solve it too.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2023-02-06T22:08:30+00:00

    I will join the club. We also have customers reporting the same issue. I hope Microsoft will come up with a solution soon.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2023-02-06T21:48:30+00:00

    Thanks for sharing! I hope we have a breakthrough soon. If I discover an answer I'll share it here too.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2023-02-06T20:15:44+00:00

    This is a perfect description of the situation with calling Word using OpenDataSource method. Thanks! We also have noticed that within an organization some workstations do not have the problem and some do. All are on the same version - we tried 2211, 2212 and 2301.

    Is it possible that a Group policy regarding trusted sites is coming into play?

    This has become a crises for us as the users are now turning off the option to ;open as a template' and can now overwrite their teammates letters.

    Thanks for any help.

    Tom Fahey

    HAB / MRI

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2023-01-27T08:46:18+00:00

    Hi - I was wondering if any one has heard back regarding this at all? We are facing the same issues currently.

    Was this answer helpful?

    0 comments No comments