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

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default Active Workbook

On Feb 4, 9:51*am, Tendresse
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Active Workbook

Thanks for your help, Carlo. Much Appreciated.

"carlo" wrote:

On Feb 4, 9:51 am, Tendresse
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
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 Hidden Workbook when Active Workbook is Closed SusanK521 Excel Programming 5 September 24th 05 12:27 AM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
How do I make an open workbook the active workbook Don Guillett[_4_] Excel Programming 0 December 30th 03 04:28 PM
Copy Modules from One workbook to Active Workbook Jim Gifford Excel Programming 1 November 18th 03 12:30 PM
Preventing opening workbook inside active workbook. Serge[_4_] Excel Programming 2 November 4th 03 07:51 PM


All times are GMT +1. The time now is 10:42 AM.

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"