Application defined or object defined error - Not Caused by Code

Hi All

Here is a strange one

I have a command button that envokes code "mnuExit" - this code does a
bunch of different things and then closes the excel file.  I have more
code in the BeforeClose and Workbook_Deactivate events.

Everything runs properly if there are no other Excel Files open -
however - IF there are other excel files open once all the code has
finished running I get a dialogue box that says:

"Applicatiob-defined or object-defined error"  there is no 1004 or
anything else - and there is nothing in my code that is causing this
error - I have stepped though all of the code - I have removed all of
the code in the BeforeClose and Workbook_Deactivate events and it is
still happening

I have even removed most of the code from "mnuExit"  only leaving:

ThisWorkbook.Saved = True
ThisWorkbook.Close

And the other strange thing about all of this is that if you "X" out
of the file and not use the "Exit Button" then none of this happens

Anyone have any thoughts on this or seen something similar?

Thanks in advance for any comments

Jeff


0
JeffTO
12/4/2009 3:42:04 PM
excel.programming 6508 articles. 2 followers. Follow

5 Replies
1424 Views

Similar Articles

[PageSpeed] 28

I have done some further testing:

I created a new workbook and put the following code:

Sub MYexit()
ThisWorkbook.Saved = True
ThisWorkbook.Close
End Sub


When I run the macro with other workbooks open or closed there is no
problem

However...

When I create a toolbar with a single button and assign MYExit to the
button - I get the same "Application-defined or object-defined error"
ONLY if other workbooks are open.

So it looks like the problem is being cause by running the macro with
a command button when other workbooks are open - again there is no
code causing this error - so I am not sure how to trap it so I can
avoid the error message being shown.

Any thoughts would be great

Thanks again,

Jeff
0
JeffTO
12/4/2009 4:20:10 PM
When you close ThisWorkbook, you are closing the workbook containing the 
running macro.  If there is more than one workbook open, Excel may be 
confused about what to do next.

If there is another workbook open, try Activating it before closing 
ThisWorkbook.

Let us know if this helps.
-- 
Gary''s Student - gsnu200909


"JeffTO" wrote:

> Hi All
> 
> Here is a strange one
> 
> I have a command button that envokes code "mnuExit" - this code does a
> bunch of different things and then closes the excel file.  I have more
> code in the BeforeClose and Workbook_Deactivate events.
> 
> Everything runs properly if there are no other Excel Files open -
> however - IF there are other excel files open once all the code has
> finished running I get a dialogue box that says:
> 
> "Applicatiob-defined or object-defined error"  there is no 1004 or
> anything else - and there is nothing in my code that is causing this
> error - I have stepped though all of the code - I have removed all of
> the code in the BeforeClose and Workbook_Deactivate events and it is
> still happening
> 
> I have even removed most of the code from "mnuExit"  only leaving:
> 
> ThisWorkbook.Saved = True
> ThisWorkbook.Close
> 
> And the other strange thing about all of this is that if you "X" out
> of the file and not use the "Exit Button" then none of this happens
> 
> Anyone have any thoughts on this or seen something similar?
> 
> Thanks in advance for any comments
> 
> Jeff
> 
> 
> .
> 
0
Utf
12/4/2009 4:28:06 PM
Hello and thanks for the reply

That did not work - before I went to the trouble of writing code to
check for open workbooks and then activating one of them I tried it
with a hard coded defined workbook ("Book9") and it did activate the
workbook but I am still getting the same error.

It has to do with running the code from the Commandbar button - when I
run the code via Tools/Macro/ and select the macro name - the code
runs fine - so I think there is something with trying to close a
workbook with a Commandbar button - at least that is what it looks
like to me.

Thanks,

Jeff
0
JeffTO
12/4/2009 4:38:02 PM
One more piece of testing  - I added a Command Button to one of the
sheets in the file and assigned the same "MyExit" macro to the new
button.

It works perfectly fine.

So - it is ONLY a problem when trying to run the code from a
commandbar button WITH other spreadsheets open.

I am sure I am not the only one to stumble accross this

BTW - I am running Excel 2003 if that makes a difference or helps at
all

Thanks.

Jeff
0
JeffTO
12/4/2009 5:41:56 PM
On 4 dec, 18:41, JeffTO <jefft...@hotmail.com> wrote:
> One more piece of testing =A0- I added a Command Button to one of the
> sheets in the file and assigned the same "MyExit" macro to the new
> button.
>
> It works perfectly fine.
>
> So - it is ONLY a problem when trying to run the code from a
> commandbar button WITH other spreadsheets open.
>
> I am sure I am not the only one to stumble accross this
>
> BTW - I am running Excel 2003 if that makes a difference or helps at
> all
>
> Thanks.
>
> Jeff

Hi everyone,
I have exactly the same problem as Jeff described in detail.. I'm
activating the code via a added menubar. I'm also using 2003.

Just hoping there is a genius out there that can help us out.

Kind regards,
Il Poniente
0
Poniente
12/20/2009 11:31:21 AM
Reply:

Similar Artilces:

Unknown Error
Anyone have any idea why I can't delete a message in a Junk folder? I'm getting a plain/simple dialog box saying "Unknown Error" and the message will not delete. Trying to move it to the Inbox, for example, returns a dialog box message saying "Can't move the items. The item could be moved. It was either already moved or deleted, or access was denied." Any ideas? Thanks, Tom Robbins tomweho@hotmail.com On Wed, 29 Nov 2006 09:14:44 -0500, "Exchange Groups" <tomweho@hotmail.com> wrote: >Anyone have any idea why I can't delete a...

Clicking one application's buttons from another application
Hello, I'd like to write an application that can click the buttons of another application running on the same machine. All my application knows about the target application is its name, the name of the window containing the buttons, and the name of the buttons. Can someone further my education in this matter in some way. Thanks, Ray Mitchell This is tricky, but possible. I actually do it in a little utility I wrote to move Outlook filters down, since the "Move Down" button doesn't autorepeat and when you have 850 anti-spam filters it becomes a bit unwieldy. What yo...

Bizarre Reports Error
For Some Unknow Reason all my reports are playing up, when i open any report now, it looks like its zoomed x1000 in the Left Top Report Header, Tried zooming out and nothing, the report just gets smaller. the only way i seem to cure this is when i click setup on the report preview and then go columns tab change some thing, change it back click apply and OK then the report Is correctly displaying its self, and im having to do this every time i open a report. any one know whats causing it? On 28 Aug, 19:06, Maurice <Maur...@discussions.microsoft.com> wrote: > Have you tried sett...

running another application from my application
Hello, I have an MDI application that on a specific case runs a 3rd party application. I use PeekMessage so my application will be drawn corretly while working on the 3rd party app. I want to prevent the user from doing anything in my application while te 3rd party app is running, until the user closes the 3rd party application. Also I want my application to be shown correctly (handle WM_PAINT, WM_DRAW etc.). Currently my application is displayed very well, but the user may do things in my application while the 3rd party app is running. I use the following code (pseuo): BOOL bRetVal = CreateP...

SMTP Protocol 7004 & 7002 Error
I have Exchange server 2003 with sp1, an my event logs a filling with errors 7004 or 7002, How should I interpreted those results : IP are external IP: Event Type: Error Event Source: MSExchangeTransport Event Category: SMTP Protocol Event ID: 7004 Date: 02.10.2005 Time: 19:23:31 User: N/A Computer: HIS10 Description: This is an SMTP protocol error log for virtual server ID 1, connection #21. The remote host "64.4.50.99", responded to the SMTP command "rcpt" with "550 Requested action not taken: mailbox unavailable ". The full command sent was "RCPT...

Application exiting with return Code 3 and ExitInstance not called neither destructors
Hey Friends It seems that i have done something very mysterious as my Application is exiting with return Code 3 and ExitInstance is not not called neither destructors. Plz Help "Vikrant_kpr" <bhatia.manish@netsity.com> wrote in message news:f62362ec.0307170549.7af528cf@posting.google.com... > Hey Friends > It seems that i have done something very mysterious as my Application > is exiting with return Code 3 and ExitInstance is not not called > neither access violation? Dear Antonio Mazzeo I have corrected the problem,it was causing due to Splash Screen Compone...

Microsoft Visual C++ Runtime error
Hi, the first time I log into Outlook each day I get "Microsoft Visual C++ Runtime library/Run time error" message pop up. It also states "C:\Programs\Office\Outlook.exe" and the text says "Application required the runtime to terminate it in an unusual way". When you "OK" it then log back in, all is fine. Anyone have any ideas how to rid myself of this annoying feature? Thanks Chris Hi, (I'm on XP), Outlook 2000-SP3 - I figured out when it happens - I have two identities set up on my machine. If one identity has outlook open, then I s...

Ideas for a Dept Level Application Support
We have an IT group that supports 50 applications and they wish to capture support time by application during course of the year. During the course of a week, any application or combination of applications can have support requests, so it is different week to week and not predictable. Essentially we are looking to park the time with appropriate application after the work is complete. We are using Project Server 2007 and have investigated the following: 1. Created a Annual Support workplan with a task per application in Project Pro with the IT group added as Enterprise resourc...

Error: "Duplicate Record A record of this type with this name already exists"
I have a strange error that started today. (I am Using V1.2) When I try to convert a lead to an account AND a contact I get the following msg: "Duplicate Record A record of this type with this name already exists. Please choose a different name and try again" At the end of the process the program is crating an Account record but not a contact record. If I try to convert the same lead again to a Contact I get the same msg. Converting a lead to an Account or Contact ONLY will work fine. The following is error is registered on the server Application log: Event Type: Error Event Sou...

Help in creating dialog based application
Hi, I am creating a dialog based application which has a main dialog with 3 buttons. 1. Address Book 2. Student List 3. Course List with which i can go to any one of the screens(which is again the dialog). when i click address book button my main dialog should be hidden/closed and i should open the address book dialog which has again some button to navigate back to main dialog/student list/course list. same kind of functionality for other two dialogs(student/course list). i thought of creating all the 3 dialogs as modeless and main dialog as parent but how i will inform the parent window to ...

Trigger error
I have a delete trigger that is trying to get information during the delete using the deleted object and I am getting the errors below. The multi-part identifier "deleted.RepCompanyID" could not be bound. The multi-part identifier "deleted.BrandID" could not be bound. The trigger code giving the error is below. p.s. This is from an old database so alternatives in constraint use would be ok. Thanks. DECLARE @RepCompany varchar(200); DECLARE @Brand nvarchar(50); DECLARE @OldInfo varchar(200); SET @RepCompany = (SELECT RepCompany FROM dbo.Rep...

DLLs being loaded for all applications
I get the following warning at system startup: "Custom dynamic link libraries are being loaded for every application. The system administrator should review the list of libraries to ensure they are related to trusted applications." How do I review the list of libraries and how do I eliminate any that should be removed? ...

persistent error for altered or nonexistent line
When I am getting a persistent error (in an imported C header), even when the particular line has been commented out, edited or even removed, where is the error coming from, and how can I flush it? c:\hand in hand\test\vorbisfile.h(27) : fatal error C1083: Cannot open include file: 'codec.h': No such file or directory "Steve Russell" <srussell@removethisinnernet.net> wrote in message news:OKDr%23BFdFHA.2180@TK2MSFTNGP12.phx.gbl... > When I am getting a persistent error (in an imported C header), even when > the particular line has been commented out, edi...

DCOM Error 10009
I have a small peer to peer network. One of the machines (XP Pro SP3) recently started to log DCOM Error 10009 every time Windows boots. There is a failure event for each machine on the network. The text of the message is: DCOM was unable to communicate with the computer COMPUTER NAME using any of the configured protocols. This is the only machine doing this, and as I mentioned it just started a few weeks ago. Nothing has changed or been installed on the system. There is no spyware or Viruses on this machine. I have removed all mapped drives and printers. Does the machi...

No Error Message in XP
Hello, I have a macro that hides some columns based on a selection from a validation list. The original spreadsheet was developed in Excel XP; I created the code in Excel 2000 because at the time I didn't realize the programmer had done the spreadsheet in XP. I ran and checked the macro which was not working, but I did not get an error in XP. I switched over to 2000, ran the macro, got an error, and because of the error message then figured out what was wrong with it. My point to this whole rambling explanation is, does anyone know why I would not get the error in XP? The er...

CRM 4.0 SETUP ERRORS
Dear all, I tried Installing CRM 4.0 professional edition in my test lab on windows server 2003 sp2, i keep receiving the following errors after folloming the implementation guide step by step: 1.error: verify domain user account SPN for microsoft dynamics CRM ASP.NET application pool account.( I use domain user account with domain admins right for the service account) 2. Error: Index was outside the bound of the array 3: SQL error: an error accured while esterblishing connection to the server, when connecting to SQL server 2005. This failure may be caused by the fact that under defa...

Converting Console Application to win32 application
I have created an MFC console application. When I run it from Windows Explorer it opens a dos box and closes the box when it terminates it logic. Is it possible to convert it so it won't open the dos box - just run without any display? If positive, please help me regarding the steps. Thanks Kalish I am not sure if you can compile MFC with a standard win32 application, but if you can, then you can simply change your main to a WinMain, and you will have the result you want. Create a Win32 Project using the Wizard, and selection Windows Application, to see an example. Remove everthing ...

is there a hotel management excel application?
The subject says is all... TIA Martyn Hi Martyn, See response to your thread in Programming. --- Regards, Norman "Cheker" <zoomer@gmail.com> wrote in message news:eNJLsRRqEHA.348@TK2MSFTNGP15.phx.gbl... > The subject says is all... > TIA > Martyn > > > ...

Microsoft Error
I bought a powerbook g4 about 7 months ago along with MS office 2004. When I installed it the first time...I had a bit of trouble because of the test drive thing...then I uninstalled that. MS office went back to working perfectly. Then, literally all of a sudden, I would click a word document off the desktop or try to open MS word program and I get this error message. The error message says "Microsoft Error Reporting....MS Word has encountered a problem...blah blah blah..." So, silly me, I uninstalled it...figuring that maybe I should reinstall later. I did that and to no avail t...

MSMQ ... authenticating application
A number of application stores messages in MSMQ. One of the server application needs to read messages that was created/stored by specific applications not to read all the messages in MSMQ. Is there any workarounds? Thank you Regards Raj "Raj" <Raj@discussions.microsoft.com> wrote in message news:6917708E-88B1-497B-A888-5038ACEA17CE@microsoft.com... >A number of application stores messages in MSMQ. One of the server > application needs to read messages that was created/stored by specific > applications not to read all the messages in MSMQ. > ...

DLL
Is there any way to detect when an application that is calling my dll is about to be destroyed? I need to close several files if the calling application has not done so, therefore I need to detect when the calling application is about to be destroyed and clean up the files and variables I have used in the dll. You need to implement DllMain, the handle your cleanup tasks when you receive a PROCESS_DETACH notification. Check out: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_initialize_non.2d.mfc_dlls.asp "Joe Estock" <jestock@NOSPAMnutexto...

ERROR saving Grid as XML
SCENARIO ======================================= I have a Grid and I want to save the values on an XML. Let me say that I am NOT using DataSet to load valus on my grid. PROBLEM ======================================= When I am saving a Grid to XML I get the following exception: "Token StartElement in state Epilog would result in an invalid XML document" SOURCE CODE ======================================= myXmlTextWriter = new XmlTextWriter (aFileName, null); myXmlTextWriter.Formatting = Formatting.Indented; myXmlTextWriter.WriteStartDocument(); myXmlTextWriter.WriteStartElem...

when replicating, I get error message, but there is no table
when replicating with my assistant, I get that there are replication errors, but when I try to open the conflicts table, I get that there are "no conflict tables" =?Utf-8?B?YmttNGVhZ2xl?= <bkm4eagle@discussions.microsoft.com> wrote in news:5246CFE9-3BC1-4411-AB08-3E7B8D67D433@microsoft.com: > when replicating with my assistant, I get that there are > replication errors, but when I try to open the conflicts table, I > get that there are "no conflict tables" You'll have to look at the tables directly. The conflict tables are called BaseTabl...

Pivot Table Error Message
I received the following message when dragging my "Products" item onto my Pivot Table. "A field in your source data has more unique items than can be used in a Pivot Table." I have 14,802 unique Product items. Does anyone know what the limitation is AND how to get around it? The following MSKB article outlines the PivotTable limits in Excel 2002, and has links to articles on other versions: XL2000: Limits of PivotTables in Microsoft Excel 2000 http://support.microsoft.com/default.aspx?id=211517 XL2002: Limits of PivotTables in Microsoft Excel 2002 http://supp...

MFC applications and Visual C++'s newer editions
Hello. When it comes to Win32, Visual Studio .NET 2005 Express Edition Beta 2 only allows the creation of console-based applications. What if one wanted to create MFC-based applications and, at the same time, be able to take advantage of the powerful and conforming C++ compiler that comes with the package? I hope that resorting to Visual C++ 6.0 is not the only option. Thank you, -- Ney Andr� de Mello Zunino "Ney Andr� de Mello Zunino" <zunino@inf.ufsc.br> wrote in message news:%23FuRyAcXFHA.584@TK2MSFTNGP15.phx.gbl... > Hello. > > When it comes to Win32, Vi...