Forum Discussion
Word Blocked Macros
Some additional findings and remarks.
Without having any Word document open, Access opens Word without any problem and the macro is executed correctly.
If I open an empty Word document before calling Word from Access, the macro error appears. After the error, it’s no problem to execute the very same macro form the empty Word document I opened before. For me this confirms that the problem isn’t in my Access coding.
We run everything locally on a PC. No Internet, no network server. Nevertheless Access starts with an error message stating “Execution form server failed”. This is strange because we don’t use any server.
I have added screen captures. I use all software in Dutch, but you’ll see what I mean. I am sure you will agree, that these messages are strange not using any files from Internet nor from any other server or network.
- Sep 14, 2022
marbel1492 This issue is caused when you use CreateObject to create an instance of Word when the Word application is already running.
Modify the code in your Access application so that it uses a construction of the following format to access the existing instance of Word if there is one.
Dim bstartApp As Boolean On Error Resume Next Set objWord = GetObject(, "Word.Application") If Err Then bstartApp = True Set objWord = CreateObject("Word.Application") End If On Error GoTo 0 'Then, at the end of your code incorporate If bstartApp = True Then objWord.Quit End If
- DPyleORFeb 08, 2023Copper Contributor
Doug_Robbins_Word_MVP . I want to say thank you for presenting a fix for the macro disabling issue. The code change from createobject() to getobject() absolutely solved my issue.
- Villi_BSep 14, 2022Copper ContributorCheck how you open the document from Access: as per Doug's answer to me on Sept 12 at 12:46 AM, my issue came from using createobject() instead of trying first with getobject(), which intercepts the eventual Word.Application instance already open (it works if a doc is open), and then resuming to createobject() if the getobject() fails. That solved my issue which happened only when I already had an open file in Word