PC Review


Reply
Thread Tools Rate Thread

Closing methods

 
 
kurt
Guest
Posts: n/a
 
      10th Nov 2006
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

 
Reply With Quote
 
 
 
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      10th Nov 2006

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


 
Reply With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      10th Nov 2006
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


 
Reply With Quote
 
kurt
Guest
Posts: n/a
 
      10th Nov 2006
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


(E-Mail Removed) 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 With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      10th Nov 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
> (E-Mail Removed) 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 With Quote
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      10th Nov 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >
> > (E-Mail Removed) 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 With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      10th Nov 2006
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)

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > >
> > > (E-Mail Removed) 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 With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      10th Nov 2006
See RunAutoMacros in VBA's help.

You have to explicitly stop the workbook_open event from firing and you have to
explicitly run the auto_open (well, if you want).

(E-Mail Removed) wrote:
>
> 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > >
> > > (E-Mail Removed) 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
> > > >
> > >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create my own asynchronous BeginXXXX methods and EndXXXX methods Varangian Microsoft C# .NET 2 15th May 2008 09:46 PM
plse send troubleshooting methods about windows xp and windowsserver2003 about configuring user rights and security methods to implement touser lakshmikanthkkp456@gmail.com DIY PC 1 11th Apr 2008 09:58 AM
Is it possible to make generalized methods that accept parameterized references to call other methods? Microsoft C# .NET 3 22nd Jun 2007 11:19 PM
proper way to pass pointers by reference from managed c++ methods to native c++ methods Scott McFadden Microsoft VC .NET 1 22nd Apr 2006 06:10 AM
Proper closing methods of a form =?Utf-8?B?Q2hyaXN0b3BoZXI=?= Microsoft C# .NET 1 30th Mar 2005 08:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:46 AM.