Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default My workbook filename

I'd appreciate any tips as to a better way to deal with the following:

I am dealing with unprotecting and protecting some data in order to do
some updates to a worksheet. I want to find a way that VBA knows my
current filename so that I can avoid using the following:

Workbooks("Data_Apr2005.xls"). _
Worksheets("Cash Flow").Protect DrawingObjects:=False

Is there a way to specify the path the user opened the file from and
the filename without hardcoding the information?

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default My workbook filename

The ThisWorkbook object will always refer to the workbook that
contains the code. So, you can use code like

ThisWorkbook.Worksheets("Cash Flow").Protect
DrawingObjects:=False

The ActiveWorkbook object will refer to the workbook that is
currently active. ThisWorkbook and ActiveWorkbook are often the
same, but not always.

ActiveWorkbook.Worksheets("Cash Flow").Protect
DrawingObjects:=False

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




wrote in message
oups.com...
I'd appreciate any tips as to a better way to deal with the
following:

I am dealing with unprotecting and protecting some data in
order to do
some updates to a worksheet. I want to find a way that VBA
knows my
current filename so that I can avoid using the following:

Workbooks("Data_Apr2005.xls"). _
Worksheets("Cash Flow").Protect DrawingObjects:=False

Is there a way to specify the path the user opened the file
from and
the filename without hardcoding the information?

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default My workbook filename

Julia, how about ,ActiveSheet.Unprotect
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

wrote in message
oups.com...
I'd appreciate any tips as to a better way to deal with the following:

I am dealing with unprotecting and protecting some data in order to do
some updates to a worksheet. I want to find a way that VBA knows my
current filename so that I can avoid using the following:

Workbooks("Data_Apr2005.xls"). _
Worksheets("Cash Flow").Protect DrawingObjects:=False

Is there a way to specify the path the user opened the file from and
the filename without hardcoding the information?

Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default My workbook filename

ThisWorkbook refers to the workbook containing the code
ActiveWorkbook refers to the workbook that has the focus

<workbook ref.Path - gives the path of the referenced workbook
<workbook ref.Fullname - gives the path and name of the referenced
workbook
<workbook ref.Name - give the name of the referenced workbook

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
I'd appreciate any tips as to a better way to deal with the following:

I am dealing with unprotecting and protecting some data in order to do
some updates to a worksheet. I want to find a way that VBA knows my
current filename so that I can avoid using the following:

Workbooks("Data_Apr2005.xls"). _
Worksheets("Cash Flow").Protect DrawingObjects:=False

Is there a way to specify the path the user opened the file from and
the filename without hardcoding the information?

Thanks!



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
vba, get filename of this workbook md[_2_] Excel Discussion (Misc queries) 3 March 29th 08 12:04 PM
Workbook name in VBA doesn't match filename.xls JoeAdidas21 Excel Discussion (Misc queries) 5 November 16th 07 03:37 PM
Saving XLS workbook with set filename levertonfamily Excel Discussion (Misc queries) 0 November 16th 06 05:52 PM
Filename in footer automatically in new workbook. cmorton89 Excel Discussion (Misc queries) 1 March 9th 06 12:52 PM
Variable Filename/Worksheet/Workbook bw Excel Programming 2 July 19th 03 07:41 PM


All times are GMT +1. The time now is 06:31 PM.

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"