Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Closing methods

He All

I have a funny problem when closing files from a macro outside the file
I want to close. That I cant imagine what is happend.

I have in my Personal.xls a macro called Close_files.

When I execute this macro the function is to close the workbook called
test.xls.

In test.xls there is a macro - Sub Workbook_BeforeClose(Cancel As
Boolean)-
in this there is an expression - Sheets("Base informations").Select


When I run macro Close_files; Sheets("Base informations").Select --
is not selected
The rest of the
code is executed as normal


When I close test.xls; Sheets("Base informations").Select - is
selected
The rest of the code is
executed as normal

Please Help

regards
Kurt

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Closing methods


kurt wrote:

He All

I have a funny problem when closing files from a macro outside the file
I want to close. That I cant imagine what is happend.

I have in my Personal.xls a macro called Close_files.

When I execute this macro the function is to close the workbook called
test.xls.

In test.xls there is a macro - Sub Workbook_BeforeClose(Cancel As
Boolean)-
in this there is an expression - Sheets("Base informations").Select


When I run macro Close_files; Sheets("Base informations").Select --
is not selected
The rest of the
code is executed as normal


When I close test.xls; Sheets("Base informations").Select - is
selected
The rest of the code is
executed as normal

Please Help

regards
Kurt


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Closing methods

Hi
I don't think event code fires when you open or close using CODE, but
then your code executing after the select is odd?
regards
Paul

kurt wrote:

He All

I have a funny problem when closing files from a macro outside the file
I want to close. That I cant imagine what is happend.

I have in my Personal.xls a macro called Close_files.

When I execute this macro the function is to close the workbook called
test.xls.

In test.xls there is a macro - Sub Workbook_BeforeClose(Cancel As
Boolean)-
in this there is an expression - Sheets("Base informations").Select


When I run macro Close_files; Sheets("Base informations").Select --
is not selected
The rest of the
code is executed as normal


When I close test.xls; Sheets("Base informations").Select - is
selected
The rest of the code is
executed as normal

Please Help

regards
Kurt


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Closing methods

Hi

The code is running smoothly in the test.xls file when I close it
directly

When I close it from the macro in Personal.xls I can follow the codes
execution, but it do not execute this step ;
That means that if I want to update something in the ("Gase
Information") sheet it will not be updated there byt on the sheet there
is active and this is odd..

regards

Kurt


skrev:
Hi
I don't think event code fires when you open or close using CODE, but
then your code executing after the select is odd?
regards
Paul


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Closing methods

It is probably trying to close a worksheet in the workbook that is running
the macro. Change it to

ThisWorkbook.Sheets("Base informations").Select


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"kurt" wrote in message
ups.com...
Hi

The code is running smoothly in the test.xls file when I close it
directly

When I close it from the macro in Personal.xls I can follow the codes
execution, but it do not execute this step ;
That means that if I want to update something in the ("Gase
Information") sheet it will not be updated there byt on the sheet there
is active and this is odd..

regards

Kurt


skrev:
Hi
I don't think event code fires when you open or close using CODE, but
then your code executing after the select is odd?
regards
Paul






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Closing methods

Hi
I thought you could not fire an Auto_Open macro, say, if you opened the
file with code. Is that not the case? (I'm too lazy to go check
myself!)
regards
Paul

Bob Phillips wrote:

It is probably trying to close a worksheet in the workbook that is running
the macro. Change it to

ThisWorkbook.Sheets("Base informations").Select


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"kurt" wrote in message
ups.com...
Hi

The code is running smoothly in the test.xls file when I close it
directly

When I close it from the macro in Personal.xls I can follow the codes
execution, but it do not execute this step ;
That means that if I want to update something in the ("Gase
Information") sheet it will not be updated there byt on the sheet there
is active and this is odd..

regards

Kurt


skrev:
Hi
I don't think event code fires when you open or close using CODE, but
then your code executing after the select is odd?
regards
Paul



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Closing methods

What has Auto_Open got to do with anything here? He is using BeforeClose
which does run from code quite happily.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ps.com...
Hi
I thought you could not fire an Auto_Open macro, say, if you opened the
file with code. Is that not the case? (I'm too lazy to go check
myself!)
regards
Paul

Bob Phillips wrote:

It is probably trying to close a worksheet in the workbook that is

running
the macro. Change it to

ThisWorkbook.Sheets("Base informations").Select


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"kurt" wrote in message
ups.com...
Hi

The code is running smoothly in the test.xls file when I close it
directly

When I close it from the macro in Personal.xls I can follow the codes
execution, but it do not execute this step ;
That means that if I want to update something in the ("Gase
Information") sheet it will not be updated there byt on the sheet

there
is active and this is odd..

regards

Kurt


skrev:
Hi
I don't think event code fires when you open or close using CODE,

but
then your code executing after the select is odd?
regards
Paul





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
Closing workbooks w/o closing Excel Barb in MD Excel Discussion (Misc queries) 3 February 15th 10 06:42 PM
Std.Dev.methods NOT WORKING SixSpeedShifter Charts and Charting in Excel 1 July 20th 05 06:32 PM
Closing VB triggers closing Excel Minilek Excel Programming 2 August 6th 04 05:17 PM
closing excel after closing a workbook CWalsh[_2_] Excel Programming 3 January 21st 04 03:33 PM
Certain methods do not work Rohit Thomas Excel Programming 4 July 9th 03 06:36 PM


All times are GMT +1. The time now is 09: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"