Hi Ian,
I can describe the reason you're seeing it. Start Word as a normal end user; you'll see "Document 1". Now, before doing anything else (IOW don't "dirty" the document) open a different document. You'll notice that Word closes the default "new page" document, thus closing it. Apparently this triggers that message, even though Word isn't actually closing (because Word now closes when the last document is closed unless you explicitly use the File/Close command - complicated).
If this were straight automation, I'd say start Word with the switch to prevent a new document from being generated. But in this case, try just setting the Saved property of this document = false so that Word thinks it's "dirty" and see if that stops Word closing it.
[Quoted Text] > I'm posting in this forum because the problem is only evident when running > code from a button in a template loaded as an addin (or from start-up). > Code snip from a VBA Form button. > ~~~~~~~ > 110 sFile = sRootPath & sDocType & "\" & Me.comboBranch & "\" & > Me.comboAnswer > '111 Me.Hide > 112 Documents.Open fileName:=sFile > 114 Documents(Me.comboAnswer).Activate > '116 Me.Show > ~~~~~~ > Line 112 gives me the error 5479, "You cannot close Microsoft Office Word > because you have a dialog box open......" > This only happens. > 1. When Word has just been opened and has created a "Document1" > 2. The Template is loaded as above. > It does NOT happen if: > 1 I close Document1 and open a new document (Document2) > 2. I close Document1 > 3. The code is run from the IDE > 4. I rerun the code after getting the error. > 5. I save Document1 as Document2 > You may note that I have tried the Me.Hide/Show, and this corrects this > error, but it brings up other problems further down the code. Activate is > to get around the SDI display as I want the document behind the form. > I have a work around by trapping the error and rerunning the button code if > this error arises. > > It sure is strange! > > Has any one had anything like this and have a better fix? >
Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-)
|