Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ThisWorkbook.close doesn't wokk :(

H

I have a pb, I have created an Excel addin an I have put the following code in it
----------
Private Sub Workbook_BeforeClose(Cancel As Boolean
MsgBox ("Try to unload"
Application.ThisWorkbook.Close savechanges:=False 'or me.Clos
End Su
---------
I have name my file unloadtest.xl
if I double clic on this file from explorer, it works ok but if I create a shortcut who launch Excel with my file in parameters, it crashes
On excel 97 it does no crash but the unload of my xla fail
on Excel 2000 it crashe

Any Idea ? if it works for you could you tell me too plz

ThX By Advanc

Arnau

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default ThisWorkbook.close doesn't wokk :(

Hi Arnaud,

Thanks for posting in the community!

From my understanding, you have created one Excel xla add-in which will
capture the Workbook_BeforeClose event. If you double-click it, Excel works
very smoothly. However, if you start this from some startup switches, in
Excel 97, the xla can not be unloaded; in Excel 2000, this xla crashes.

In Excel 97, this is one known issue for the Workbook_BeforeClose event in
VBA. I'd suggest you can check the kb article for one workaround.
172749 XL97: Unable to Close File Activated by WorkbookBeforeClose
http://support.microsoft.com/?id=172749

In Excel 2000, since I don't know what Startup switches you used to start
Excel with the XLA add-in, I am not sure whether this event caused the
crash or something else. Moreover, I am also not sure whether you have
installed the latest office updates and patches for Office 2000 from
Office.Microsoft.com. If not, please go to the link to perform one
automatic update checking.
http://office.microsoft.com/search/r...331033&Origin=
HH011136791033&CTT=5

After that, if the issue remains no matter existing in 97 or 2000, I'd
suggest you can give me one detailed repro steps ( for 97 or 2000 or both )
with that add-in file ( or one simplified sample add-in which can crash
Excel2000 ) so that I can test this for you.

Look forward to your reply. Enjoy a nice weekend!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ThisWorkbook.close doesn't wokk :(

Tanks for your fast answer :
Yes You have well understood my problem :
But I don't use particular parameters, only the name of my xla file like this
"C:\Program Files\Microsoft Office 97\Office\EXCEL.EXE" "C:\MyLocalDucuments\UnloadAddins.xla
or
"C:\Program Files\Microsoft Office\Office\EXCEL.EXE" "C:\MyLocalDucuments\UnloadAddins.xla
depending where are my excel application and my addin located

I don't know how to send you the files then I will Email them to You
I have installed SP3 of Excel 2000 but the bug is still here

Step to reproduce my problem
Create an excel file renome it to .xla and set his isaddin property to true
insert this code in ThisWorkboo

---------------- start of code of code ---------------
Public closeLater As Boolea

Private Sub Workbook_BeforeClose(Cancel As Boolean
'set closeLater to false to call the close method no
'set closeLater to true to call the close method in 5 se

closeLater = Fals
MsgBox ("Try to auto-unload"

If (closeLater = False) The
Application.ThisWorkbook.Close savechanges:=Fals
Els
Application.OnTime Now + TimeValue("00:00:05"), "thisworkbook.KillLater
End I
End Su

Private Sub KillLater(
Application.ThisWorkbook.Close savechanges:=Fals
End Su
---------------- end of code ---------------

If I set closeLater to false then
-- crash in Excel 200
-- nothing happens in excel 9

If I set closeLater to true then
-- the adin is closed in 2000 like in 97 like I want but it is only a workaround
I don't want use this workaround because it can implies others bug and it is very dirty

Thx by advanc

arnau

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default ThisWorkbook.close doesn't wokk :(

Hi Arnaud,

Thank you for replying!

I have received your files. I am researching this issue for you. I will
post back when I have any result then.

Enjoy a nice weekend!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default ThisWorkbook.close doesn't wokk :(

Hi Arnaud,

Thank you for the detailed information about the repro!

From my view, you code will work very well for one workbook-scope workbook_beforeclose event. However, you are using them in one add-in
which has the application scope. This add-in can't locate which workbook to perform the operation even there is only one. This is the reason why
you get the crash or find some odd behavior. I'd suggest you can change the code from the original to the one below, adding one loop to search
the corresponding workbook and retrieve the information for your scenario:
'Code begin ----------------------------------------------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim wbk As Workbook
For Each wbk In Application.Workbooks
'you can specify your own condition
' for example, you can also check your own CloseLater here.
If wbk.Saved = False Then
'perform some operations
....
'in sample, save the workbook directly
wbk.save
End If
Next
End Sub
'Code end ------------------------------------------------------

Please feel free to let me know if you have any further questions. I am standing by to be of assistance.

Have a nice day!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default ThisWorkbook.close doesn't wokk :(

Hi

thanks for your answer, but it is not exactly what I want :
I have an addin in excel and a workbook scope
I modify the workbook scope and try to exit excel
The popup who ask me if I want to save apprears
Then I think ho my god no I don't want to quit !!
then I choose the cancel butto
My Workbook_BeforeClose event in the ADDIN has been called and the line thisworkbook.close (who is the addin) has been execute
Then the addin must have been unloaded !!
But it is not the case, my addin is still here !!

The problem in my true application (not the sample I have sent you) is that my addin has unloaded other addins but not himself !!! then when the user clic again on the .xla file, excel says himself: hey !!! I have already loaded this file nothing to do !!! and the addin that my main addin must launch are not loaded at all !!

Then My question is : how to do an addin who unload itself
Please launch the xla sample I have sent you to test and read the file "readfirst.txt" who explain how to reproduce step by step my problem, it take a very few times

Thx by advanc

Arnau

----- Wei-Dong Xu [MSFT] wrote: ----

Hi Arnaud

Thank you for the detailed information about the repro

From my view, you code will work very well for one workbook-scope workbook_beforeclose event. However, you are using them in one add-in
which has the application scope. This add-in can't locate which workbook to perform the operation even there is only one. This is the reason why
you get the crash or find some odd behavior. I'd suggest you can change the code from the original to the one below, adding one loop to search
the corresponding workbook and retrieve the information for your scenario
'Code begin ---------------------------------------------------
Private Sub Workbook_BeforeClose(Cancel As Boolean

Dim wbk As Workboo

For Each wbk In Application.Workbook
'you can specify your own conditio
' for example, you can also check your own CloseLater here

If wbk.Saved = False The
'perform some operation
...
'in sample, save the workbook directl

wbk.sav

End I

Nex
End Su
'Code end ------------------------------------------------------

Please feel free to let me know if you have any further questions. I am standing by to be of assistance.

Have a nice day

Wei-Dong X
Microsoft Product Support Service
Get Secure! - www.microsoft.com/securit
This posting is provided "AS IS" with no warranties, and confers no rights



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default ThisWorkbook.close doesn't wokk :(

Hi Arnaud,

Thank you for replying!

I have built one sample for you and sent it to you. If you haven't received it, please mail me or post one message in this thread. I will send you
again.

Best regards,

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ThisWorkbook.close doesn't wokk :(

Hi
Thx for your sample :
ok i I have well anderstood, there is truly a bug for an addin to close itself
And you propose to manage what excel must do with the loading and unloading of excel add-ins
- In your sample, you deal with addins installed in excel but how to deal with addin that are not integrated with excel
- If there are other addins loaded but not added to excel (not in list from tools-Add-Ins), how can I be sure to be called before others
- There is still a problem with the I18N and the dialog who display the message warning and the message. by sample in excel 2000 the message who ask to save or not modification in workbook is displayed in an asistant but in excel97 in a messagebox like yours
like you can see your hack is a good idea but there are some problem and maybe other that I don't know :(

Is there a patch or microsoft will do one for this bug

Thx Arnau

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default ThisWorkbook.close doesn't wokk :(

Hi Arnaud,

Thanks for the replying!

For the first question, I don't know in which scenario, the un-installed add-in will affect the excel execution.

For the second question, each COM add-in has its own registry setting for the startup type. This two kb article will introduce the difference between
the two types of add-in.
291392 INFO: Excel COM Add-ins and Automation Add-ins
http://support.microsoft.com/?id=291392

290868 HOWTO: Configure an Office COM Add-In for All Users on System
http://support.microsoft.com/?id=290868

For the third question, if the message is shown in the assistance window, I'd suggest you can disable the assistance.

Please feel free to let me know if you have any further questions. Enjoy a nice weekend!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default ThisWorkbook.close doesn't wokk :(

Hi Arnard,

I have researched further for you on this issue. However, based on my research, the xla is deisgned to work after the installation. If you want to
double-click it or load it from the commandline, this goes into editting mode. Then in the editting mode, as you have seen, the Excel event can be
handled by the xla which is used for your modification on this add-in. You can see this as design time, not runtime. When the add-in is installed,
the xla works in runtime. My sample will illustrator how to load/unload add-in for you.

However, I suddenly realized your requirement may be one very wonderful product enhancement. So I'd suggest you can forward this to Microsoft
Wish program. Let us know how we can improve our products.
1. World Wide Web
a)In Internet Explorer 6, click Send Feedback on the Help menu and then click the link in the Product Suggestion section of the page that
appears.
b)In Windows XP, click Help and Support on the Start menu. Click Send your feedback to Microsoft, and then fill out the Product Suggestion page
that appears.
c)Visit the following Microsoft Web site:
http://www.microsoft.com/ms.htm
d)Click Microsoft.com Guide in the upper-right corner of the page and then click Contact Us . Click the link in the Product Suggestion section of
the page that appears.
e)Visit the following Microsoft Product Feedback Web site
http://register.microsoft.com/mswish/suggestion.asp
and then complete and submit the form.

2. E-mail - To send comments or suggestions via e-mail, use the following Microsoft Wish Program e-mail address, .

3. FAX - To send comments or suggestions via FAX, use the following Microsoft FAX number, (425) 936-7329.
NOTE : Address the FAX to the attention of the Microsoft Wish Program.

4. US Mail - To send comments or suggestions via US Mail, use the following Microsoft mailing address:
Microsoft Corporation
Attn. Microsoft Wish Program
One Microsoft Way
Redmond, WA 98052-6399

Please feel free to let me know if you have any further questions.

Best Regards,
Wei-Dong Xu
Microsoft Product Support Services
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
----------------
MORE INFORMATION
Each product suggestion is read by a member of our product feedback team, classified for easy access, and routed to the product or service team
to drive Microsoft product and/or service improvements. Because we receive an abundance of suggestions (over 69,000 suggestions a year!) we
can't guarantee that each request makes it into a final product or service. But we can tell you that each suggestion has been received and is
being reviewed by the team that is most capable of addressing it.

All product or service suggestions received become the sole property of Microsoft. Should a suggestion be implemented, Microsoft is under no
obligation to provide compensation.



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
ThisWorkbook of personal.xls Jack Sons Excel Discussion (Misc queries) 4 August 29th 07 04:28 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM
Calling Sub(s) from ThisWorkbook BSchwerdt Excel Programming 1 December 11th 03 01:36 AM
ThisWorkbook Macros Random Excel Programming 1 August 16th 03 04:03 PM


All times are GMT +1. The time now is 02:11 AM.

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

About Us

"It's about Microsoft Excel"