+ Reply to Thread
Results 1 to 4 of 4

My workbook filename

  1. #1

    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. #2
    Chip Pearson
    Guest

    Re: 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




    <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Paul B
    Guest

    Re: 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

    <[email protected]> wrote in message
    news:[email protected]...
    > 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. #4
    Tom Ogilvy
    Guest

    Re: 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


    <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1