Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel-2007 problem while closing the files

Hi,

In Excel-2007 addin, in ShutDown functionality for closing all open files.

I have written following code:

Try
'Close All Open documents
Dim exlWorkBook As Excel.Workbook
If Application.Workbooks.Count = 1 Then
Application.ActiveWorkbook.Close(False)
Else
For Each exlWorkBook In Application.Workbooks
exlWorkBook.Close(False)
Next
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try


The exception is "Exception from HRESULT: 0x800AC472".



Any suggesstions will be helpful.

Thanks
Mahesh

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Excel-2007 problem while closing the files

For Each exlWorkbook In Application.Workbooks
If Not ThisWorkbook Is exlWorkbook Then
exlWorkbook.Close False
End If
Next
--
Jim Cone
Portland, Oregon USA




"Mahesh_D"

wrote in message
Hi,
In Excel-2007 addin, in ShutDown functionality for closing all open files.
I have written following code:

Try
'Close All Open documents
Dim exlWorkBook As Excel.Workbook
If Application.Workbooks.Count = 1 Then
Application.ActiveWorkbook.Close(False)
Else
For Each exlWorkBook In Application.Workbooks
exlWorkBook.Close(False)
Next
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

The exception is "Exception from HRESULT: 0x800AC472".
Any suggesstions will be helpful.
Thanks
Mahesh

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel-2007 problem while closing the files

Hi,

Thanks Jim for your reply.

I have tried code given by you:

Try
Dim exlWorkBook As Excel.Workbook
For Each exlWorkBook In Application.Workbooks
If Not Application.ThisWorkbook Is exlWorkBook Then
exlWorkBook.Close(False)
End If
Next
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

But it leads to exception as: "Exception from HRESULT: 0x800A03EC"

This exception value is new as compared to last one which i got. It is
occuring because of line:
"If Not Application.ThisWorkbook Is exlWorkBook"



Thanks
mahesh







"Jim Cone" wrote:

For Each exlWorkbook In Application.Workbooks
If Not ThisWorkbook Is exlWorkbook Then
exlWorkbook.Close False
End If
Next
--
Jim Cone
Portland, Oregon USA




"Mahesh_D"

wrote in message
Hi,
In Excel-2007 addin, in ShutDown functionality for closing all open files.
I have written following code:

Try
'Close All Open documents
Dim exlWorkBook As Excel.Workbook
If Application.Workbooks.Count = 1 Then
Application.ActiveWorkbook.Close(False)
Else
For Each exlWorkBook In Application.Workbooks
exlWorkBook.Close(False)
Next
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

The exception is "Exception from HRESULT: 0x800AC472".
Any suggesstions will be helpful.
Thanks
Mahesh


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Excel-2007 problem while closing the files

I would assume then that your code is not in a workbook.
--
Jim Cone
Portland, Oregon USA



"Mahesh_D"

wrote in message
Hi,Thanks Jim for your reply.
I have tried code given by you:

Try
Dim exlWorkBook As Excel.Workbook
For Each exlWorkBook In Application.Workbooks
If Not Application.ThisWorkbook Is exlWorkBook Then
exlWorkBook.Close(False)
End If
Next
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

But it leads to exception as: "Exception from HRESULT: 0x800A03EC"
This exception value is new as compared to last one which i got. It is
occuring because of line:
"If Not Application.ThisWorkbook Is exlWorkBook"
Thanks
mahesh







"Jim Cone" wrote:

For Each exlWorkbook In Application.Workbooks
If Not ThisWorkbook Is exlWorkbook Then
exlWorkbook.Close False
End If
Next
--
Jim Cone
Portland, Oregon USA




"Mahesh_D"

wrote in message
Hi,
In Excel-2007 addin, in ShutDown functionality for closing all open files.
I have written following code:

Try
'Close All Open documents
Dim exlWorkBook As Excel.Workbook
If Application.Workbooks.Count = 1 Then
Application.ActiveWorkbook.Close(False)
Else
For Each exlWorkBook In Application.Workbooks
exlWorkBook.Close(False)
Next
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

The exception is "Exception from HRESULT: 0x800AC472".
Any suggesstions will be helpful.
Thanks
Mahesh


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel-2007 problem while closing the files

Hi Jim,

That code is written inside Excel addins ThisAddIn_Shutdown() event.
So it should work, but its not happening that way.



Thanks
mahesh



"Jim Cone" wrote:

I would assume then that your code is not in a workbook.
--
Jim Cone
Portland, Oregon USA



"Mahesh_D"

wrote in message
Hi,Thanks Jim for your reply.
I have tried code given by you:

Try
Dim exlWorkBook As Excel.Workbook
For Each exlWorkBook In Application.Workbooks
If Not Application.ThisWorkbook Is exlWorkBook Then
exlWorkBook.Close(False)
End If
Next
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

But it leads to exception as: "Exception from HRESULT: 0x800A03EC"
This exception value is new as compared to last one which i got. It is
occuring because of line:
"If Not Application.ThisWorkbook Is exlWorkBook"
Thanks
mahesh







"Jim Cone" wrote:

For Each exlWorkbook In Application.Workbooks
If Not ThisWorkbook Is exlWorkbook Then
exlWorkbook.Close False
End If
Next
--
Jim Cone
Portland, Oregon USA




"Mahesh_D"

wrote in message
Hi,
In Excel-2007 addin, in ShutDown functionality for closing all open files.
I have written following code:

Try
'Close All Open documents
Dim exlWorkBook As Excel.Workbook
If Application.Workbooks.Count = 1 Then
Application.ActiveWorkbook.Close(False)
Else
For Each exlWorkBook In Application.Workbooks
exlWorkBook.Close(False)
Next
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

The exception is "Exception from HRESULT: 0x800AC472".
Any suggesstions will be helpful.
Thanks
Mahesh





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Excel-2007 problem while closing the files

I cannot help you - I am only aware of two workbook events that
might be similar to what you are using...

Private Sub Workbook_AddinUninstall()
- and -
Private Sub Workbook_BeforeClose(Cancel As Boolean)
--
Jim Cone
Portland, Oregon USA



"Mahesh_D"

wrote in message
Hi Jim,
That code is written inside Excel addins ThisAddIn_Shutdown() event.
So it should work, but its not happening that way.
Thanks
mahesh



"Jim Cone" wrote:

I would assume then that your code is not in a workbook.
--
Jim Cone
Portland, Oregon USA



"Mahesh_D"

wrote in message
Hi,Thanks Jim for your reply.
I have tried code given by you:

Try
Dim exlWorkBook As Excel.Workbook
For Each exlWorkBook In Application.Workbooks
If Not Application.ThisWorkbook Is exlWorkBook Then
exlWorkBook.Close(False)
End If
Next
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

But it leads to exception as: "Exception from HRESULT: 0x800A03EC"
This exception value is new as compared to last one which i got. It is
occuring because of line:
"If Not Application.ThisWorkbook Is exlWorkBook"
Thanks
mahesh







"Jim Cone" wrote:

For Each exlWorkbook In Application.Workbooks
If Not ThisWorkbook Is exlWorkbook Then
exlWorkbook.Close False
End If
Next
--
Jim Cone
Portland, Oregon USA




"Mahesh_D"

wrote in message
Hi,
In Excel-2007 addin, in ShutDown functionality for closing all open files.
I have written following code:

Try
'Close All Open documents
Dim exlWorkBook As Excel.Workbook
If Application.Workbooks.Count = 1 Then
Application.ActiveWorkbook.Close(False)
Else
For Each exlWorkBook In Application.Workbooks
exlWorkBook.Close(False)
Next
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try

The exception is "Exception from HRESULT: 0x800AC472".
Any suggesstions will be helpful.
Thanks
Mahesh



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003/Excel 2007 Add-Ins Do Not Reset after closing files Harry G Excel Programming 0 August 21st 08 02:26 PM
Problem when closing Excel 2007 and with Add-ins Gary Excel Discussion (Misc queries) 1 January 4th 08 01:02 AM
Problem opening Excel 2007 files Michael Julson Excel Discussion (Misc queries) 18 December 2nd 07 05:21 PM
Excel 2003/2007 Crash when opening/closing files Richard NYC Excel Discussion (Misc queries) 1 October 18th 07 08:22 AM
Problem loading Excel 2007 files in Excel 2003 BrianW Excel Discussion (Misc queries) 3 September 12th 07 08:16 PM


All times are GMT +1. The time now is 04:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"