Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

Word2003 generating error 5479 - You cannot close Microsoft Office Word .....

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ian Bayly - 20 Mar 2007 02:00 GMT
Apologies for cross posting, I posted similar to WordVBA addins, but the
more I investigate the more it relates to Wd2003 and UserForms.

Create a template, add a UserForm1 with CommandButton1, add a Module with
Sub Main.
Sub Main code = UserForm1.Show
CommandButton1 code  below
Private Sub CommandButton1_Click()
   Dim sFile As String
   sFile = "<any valid document path & name>"
   Documents.Open FileName:=sFile
End Sub

Save Template
Close Word
Open Word (so there is a Document1 created)
Tools - Add templates - add your template globally.
Tools macros - Run "Main" - click on CommandButton1 and you should get
error:
"Run time error 5479 You cannot close Microsoft Office Word because a
dialog box is open.  Click OK, switch to Word and then close the dialog
box."
Where am I trying to Close word?

This will not happen if:
I do not have a clean Document1 created by opening word, type something in
Document1 - OK, Create Document2, close Document1 - OK, close Document1
(leaving no documents open) - OK, I do not load the template globally but
run from the open  template - OK, I run Main a second .... time - OK.

It will go away with:
Me.hide
Documents.Open FileName:=sFile
Me.show

I have gone back through Word 2002, Word 2000 neither of which show this
anomaly.

Any suggestions apart from the Hide/Show as a work around and as to why the
problem is so specific.

TIA

Ian B
Perry - 06 Apr 2007 11:19 GMT
What happens if you give the Main() macro another name, like:
Sub TestMain() and retry all yr actions?

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE

> Apologies for cross posting, I posted similar to WordVBA addins, but the
> more I investigate the more it relates to Wd2003 and UserForms.
[quoted text clipped - 40 lines]
>
> Ian B
Ian Bayly - 09 Apr 2007 23:04 GMT
Thanks for the interest Perry.
I renamed userform and macro as suggested but problem still arises.

I've got the workaround in place (Hide/Show) so it's a not a matter of
urgency, but rather, curiosity!

Cheers

Ian B

> What happens if you give the Main() macro another name, like:
> Sub TestMain() and retry all yr actions?
[quoted text clipped - 52 lines]
>>
>> Ian B
Perry - 09 Apr 2007 23:23 GMT
> Apologies for cross posting, I posted similar to WordVBA addins, but the
> more I investigate the more it relates to Wd2003 and UserForms.
Hmm, I doubt this.
No relevant changes have been made to the MS Word object modell
regarding userforms (or the usage of such) as opposed to XP or 2000.

The problem -most likely- will have a different cause.
I can't duplicate yr scenario because I don't use the target Office (Word)
version(s) ...

There are a couple of pointers I could give you:
- have you checked your code in a scenario in which no other addins are
loaded?

- have you checked (menu: Tools | Options) whether all documents are grouped
in the Taskbar?
Change this setting and try yr code again. Any results?

If no results, you'll have to kick in more code for people to investigate.

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE

> Thanks for the interest Perry.
> I renamed userform and macro as suggested but problem still arises.
[quoted text clipped - 62 lines]
>>>
>>> Ian B
Ian Bayly - 11 Apr 2007 03:25 GMT
Perry

I have re-tested as you suggested, ie no addins, changing MDI-SDI settings
still have error. I also created a new Normal.dot.
The curious thing is how specific the circumstances are to be to reproduce
the problem.

Code is minimal thus:
~~~~~
Sub TestIt()
   myForm.Show
End Sub
~~~~~
Private Sub CommandButton1_Click()
   Dim sFile As String
   sFile = "C:\Documents and Settings\Ian\My Documents\Document2.doc"
   Documents.Open FileName:=sFile
End Sub
~~~~~

Cheers

Ian B

>> Apologies for cross posting, I posted similar to WordVBA addins, but the
>> more I investigate the more it relates to Wd2003 and UserForms.
[quoted text clipped - 90 lines]
>>>>
>>>> Ian B
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.