View Single Post
 
Old 01-23-2011, 01:15 AM
hansj hansj is offline Windows Vista Office 2010 32bit
Novice
 
Join Date: Jan 2011
Posts: 1
hansj is on a distinguished road
Default Solution with normal.dotm?

I encountered the same problem with design mode in another context. Every time I opened a document (that contains an AutoOpen procedure), I was told that code could not be executed in design mode.

The following solution worked. Place this procedure in normal.dotm:

Private Sub AutoOpen()

Dim Index As Byte

With ActiveDocument.VBProject
For Index = 1 To .VBComponents.count
With .VBComponents(Index)
If .HasOpenDesigner Then .DesignerWindow.Close
End With
Next
End With

End Sub

"Private" to ensure that there will be no conflict with other "AutoOpen" procedures.

I found this code somewhere on the net. My only contribution is placing it universally functioning in Normal.dotm (and using "Byte" in stead of "Long").

The funny thing is that after having closed and opened Word one or two times I could remove this piece of code from Normal.dotm - and the problem was gone.

Best wishes
HansJ
Reply With Quote