If you ever have this problem, check if the [WayBack] ddeexec key word opening Word documents has a [REM_DDE_EXEC]
prepended.
If so: remove it.
Background
ddeexec
is used by the Windows Explorer to open a file through DDE (because that usually is a lot faster than starting a new proces) as explained by [WayBack] Taming Microsoft Word 2007’s File Associations and Document Windows, Part One — Within Windows, which – since it is now only in the WayBack machine – I quote in full:
One of the gripes Paul had was with the z-order of his open windows being tampered with when opening two (or more) Microsoft Word documents. At first I thought of saying, what the hell are you talking about Paul, but resorted to the less abrasive: What?
Paul explained that if you open a Word document, minimize it, open an Excel spreadsheet, then finally open another document, both Word windows come to front, preventing you from ALT-Tab’ing to the spreadsheet you were working in. Come again, right?
Okay, here’s a video to make things a little easier to understand.
Get the latest Flash Player to see this player.
Given this appears to be an issue with the invocation of Word through a file type association (i.e. double-clicking), I jumped into HKEY_CLASSES_ROOT\Word.Document.12\shell\Open\command to check out the file association keys and parameters. The default value was set to:
C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE” /n /dde
As per KB210565, /n instructs Word to starts a new instance of itself with no document open (would normally be a blank page). /dde, sadly undocumented, instructs Word to fire up its “DDE server”. Seeing as there is no %1 argument here, you’re probably wondering how Word opens the document you double-clicked…
Back in the 16-bit computing era, an inter-process communication method called Dynamic Data Exchange (DDE) was created, with the purpose of allowing data to be shared between applications. Today, with the advent of technologies such as COM and OLE, DDE isn’t very useful, but you’ll still find it in use deep within the bowels of Windows. You can read more about DDE on MSDN, Wikipedia, and on Raymond Chen’s blog.
Alright, so to instruct the shell that it must speak old DDE tongue with Word, an additional key must be present: HKEY_CLASSES_ROOT\Word.Document.12\shell\Open\ddeexec. This key, and the values beneath, instruct the shell how to inform Word, via DDE, that the user is trying to open a document. You’ll notice the default value for this key has FileOpen(“%1”), an instruction that merely simulates clicking File –> Open.
In layman’s terms, here’s what happens in Paul’s case. Bear with me folks.
First document invocation:
- Paul double-clicks a .docx file
- The shell (Windows Explorer) checks the registry for information on dealing with the ‘open’ action, notices ddeexec key, and goes down the DDE speak route
- The shell sends out a broadcast asking for someone to step forward and handle Word requests
- A DDE server accepting Word requests doesn’t respond (as it’s not running), therefore the shell fires up a new instance of a DDE server using the command value (i.e.
winword /n /dde
)- The shell sends the FileOpen(%1) instruction to the new instance of Word.
- Document opens.
- Paul minimizes the document and opens other windows…
Second document invocation:
- Paul double-clicks a .docx file
- The shell (Windows Explorer) checks the registry for information on dealing with the ‘open’ action, notices ddeexec key, and goes down the DDE speak route
- The shell sends out a broadcast asking for someone to step forward and handle Word requests
- A DDE server accepting Word requests responds (Paul’s previous document).
- The shell sends the
FileOpen(%1)
instruction to the existing instance of Word.- The existing instance of Word brings its window to front to handle the FileOpen instruction
- Paul screams.
Make sense now?
Same for [WayBack] Taming Microsoft Word 2007’s File Associations and Document Windows, Part Two – Within Windows:
Due to the way Word was designed, there doesn’t appear to be an easy solution to preserve the use of the DDE command and keep window z-order intact (on our end). In Connect lingo, this would have probably been marked WILLNOTFIX. Thankfully, we can tweak the registry a bit to alter the open behavior, therefore making Paul Thurrott happy.
Here is some very important information I’m required to inform you about:
- Each document opened will now spawn a new winword.exe process.
- Changing behavior for other actions (e.g. print) is out of this guide’s scope
- Changing behavior for other applications (e.g. Powerpoint, Excel) is out of this guide’s scope.
- Backing up the registry, undoing the changes, or other otherwise covering your ass is out of this guide’s scope.
Okay, let’s dig in! First, let’s brush up on some registry terminology with a cleverly produced picture.
That committed to non-pageable memory, let’s continue by altering the open behavior for legacy documents (.doc files)…
- With an elevated registry editor, navigate to HKEY_CLASSES_ROOT\Word.Document.8\shell\Open key.
- Rename the ddeexec sub-key to ddeexec.disabled.
- Navigate to the HKEY_CLASSES_ROOT\Word.Document.8\shell\Open\command key and rename the command value to command.disabled. Do not confuse the command value with the command key!
- Double-click the (Default) value and append “%1” (including quotes)to the end of the data string.
- Verify that legacy documents open in a new process upon every invocation.
… and now lets alter the open behavior for new documents (.docx files) …
- With an elevated registry editor, navigate to HKEY_CLASSES_ROOT\Word.Document.12\shell\Open key.
- Rename the ddeexec sub-key to ddeexec.disabled.
- Navigate to the HKEY_CLASSES_ROOT\Word.Document.12\shell\Open\command key and rename the command value to command.disabled. Do not confuse the command value with the command key!
- Double-click the (Default) value and append “%1” (including quotes)to the end of the data string.
- Verify that new documents open in a new process upon every invocation.
Okay, what did we just do? We simply disabled the DDE-related keys (just in case you need to restore them) and altered the launch command to include the document, you double-click, as a command line parameter, since the DDE FileOpen command will no longer be sent. Easy!
For those looking to automate this process, say for an entire enterprise-wide deployment, cough, you can use my PowerShell script. Just paste it into the PowerShell window and pray you don’t see red.
The PowerShell Script
[WayBack] uncouple_dde_word.txt:
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT Rename-Item -Path HKCR:\Word.Document.8\shell\Open\ddeexec -NewName ddeexec.disabled Rename-Item -Path HKCR:\Word.Document.12\shell\Open\ddeexec -NewName ddeexec.disabled Rename-ItemProperty -Path HKCR:\Word.Document.8\shell\Open\command -Name command -NewName command.disabled Rename-ItemProperty -Path HKCR:\Word.Document.12\shell\Open\command -Name command -NewName command.disabled Set-ItemProperty -Path HKCR:\Word.Document.8\shell\Open\command\ -Name "(default)" ` ((Get-ItemProperty -Path HKCR:\Word.Document.8\shell\Open\command\)."(default)" + " ""%1""") Set-ItemProperty -Path HKCR:\Word.Document.12\shell\Open\command\ -Name "(default)" ` ((Get-ItemProperty -Path HKCR:\Word.Document.12\shell\Open\command\)."(default)" + " ""%1""")
–jeroen
via: [WayBack] Multiple instances of Word launching when opening files from Explorer window.