Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Minnesota, USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Determining if a File is Open (Office 2003)

    I have a procedure that copies month-end data from individual source files to a summary trend workbook. The department that creates the source files modified one page for one affiliate. Therefore, the code I use for the other 15 won't work for that one oddball file. This impacts TWO lines of code.

    I want to check to see if that one odd file is the one currently being processed. If it is, do X, if not, do Y.

    How can I ask Excel to check to see what file is open? There is nothing in this sub that has file information; it processes files that are opened elsewhere in the project.

    Thanks!

    Nancy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Determining if a File is Open (Office 2003)

    You can look at ActiveWorkbook.Name:

    If ActiveWorkbook.Name = "This.xls" Then
    ' code to execute for This.xls
    ...
    Else
    ' code to execute for all other workbooks
    ...
    End If

  3. #3
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Minnesota, USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Determining if a File is Open (Office 2003)

    Perfect! I was trying to make it much more difficult.

    Thanks for your help.

    Nancy

Posting Permissions

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