PC Review


Reply
Thread Tools Rate Thread

Active Workbook

 
 
Tendresse
Guest
Posts: n/a
 
      4th Feb 2008
Hello all,
I'm a bit confused on when we need to use the 'ActiveWorkbook' keyword when
writing VBA code. For example, to unprotect a sheet, i normally use the
statement:

ActiveSheet.Unprotect

I'm wondering if that's good enough or I am supposed to go one level up by
referring to the workbook the activesheet belongs to, eg:

ActiveWorkbook.ActiveSheet.Unprotect

I'm using Excel 2003.
Many thanks in advance
Tendresse



 
Reply With Quote
 
 
 
 
carlo
Guest
Posts: n/a
 
      4th Feb 2008
On Feb 4, 9:51*am, Tendresse <Tendre...@discussions.microsoft.com>
wrote:
> Hello all,
> I'm a bit confused on when we need to use the 'ActiveWorkbook' keyword when
> writing VBA code. For example, to unprotect a sheet, i normally use the
> statement:
>
> ActiveSheet.Unprotect
>
> I'm wondering if that's good enough or I am supposed to go one level up by
> referring to the workbook the activesheet belongs to, eg:
>
> ActiveWorkbook.ActiveSheet.Unprotect
>
> I'm using Excel 2003.
> Many thanks in advance
> Tendresse


Hi Tendresse

As far as i know Excel assumes Activeworkbook and Activesheet if you
omit them.
With your example for unprotecting it therefore doesn't matter if you
put the activeworkbook or not, on the other hand the activesheet is
needed because you have to tell excel what you want to unprotect.
If you take an expression like range you can write like that:
activeworkbook.activesheet.range
activesheet.range
or just
range
it's all the same.

hope that helps

Carlo
 
Reply With Quote
 
Tendresse
Guest
Posts: n/a
 
      4th Feb 2008
Thanks for your help, Carlo. Much Appreciated.

"carlo" wrote:

> On Feb 4, 9:51 am, Tendresse <Tendre...@discussions.microsoft.com>
> wrote:
> > Hello all,
> > I'm a bit confused on when we need to use the 'ActiveWorkbook' keyword when
> > writing VBA code. For example, to unprotect a sheet, i normally use the
> > statement:
> >
> > ActiveSheet.Unprotect
> >
> > I'm wondering if that's good enough or I am supposed to go one level up by
> > referring to the workbook the activesheet belongs to, eg:
> >
> > ActiveWorkbook.ActiveSheet.Unprotect
> >
> > I'm using Excel 2003.
> > Many thanks in advance
> > Tendresse

>
> Hi Tendresse
>
> As far as i know Excel assumes Activeworkbook and Activesheet if you
> omit them.
> With your example for unprotecting it therefore doesn't matter if you
> put the activeworkbook or not, on the other hand the activesheet is
> needed because you have to tell excel what you want to unprotect.
> If you take an expression like range you can write like that:
> activeworkbook.activesheet.range
> activesheet.range
> or just
> range
> it's all the same.
>
> hope that helps
>
> Carlo
>

 
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
Copy Range from Open Workbook to Active Workbook Forgone Microsoft Excel Programming 0 17th Jul 2009 01:46 AM
Closing Hidden Workbook when Active Workbook is Closed =?Utf-8?B?U3VzYW5LNTIx?= Microsoft Excel Programming 5 24th Sep 2005 12:27 AM
copy worksheet from closed workbook to active workbook using vba =?Utf-8?B?bWFuZ28=?= Microsoft Excel Worksheet Functions 6 9th Dec 2004 07:55 AM
How do I make an open workbook the active workbook Todd@sympatico.ca Microsoft Excel Programming 1 30th Dec 2003 04:28 PM
Preventing opening workbook inside active workbook. Serge Microsoft Excel Programming 2 4th Nov 2003 07:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:51 PM.