+ Reply to Thread
Results 1 to 36 of 36

ByPassing Passwords when pulling stats from external password-protected files

Hybrid View

jameztown ByPassing Passwords when... 05-24-2010, 01:33 PM
royUK Re: ByPassing Passwords when... 05-24-2010, 02:12 PM
Leith Ross Re: ByPassing Passwords when... 05-24-2010, 02:15 PM
jameztown Re: ByPassing Passwords when... 05-24-2010, 04:57 PM
Leith Ross Re: ByPassing Passwords when... 05-24-2010, 07:08 PM
jameztown Re: ByPassing Passwords when... 05-24-2010, 08:57 PM
Leith Ross Re: ByPassing Passwords when... 05-24-2010, 09:16 PM
jameztown Re: ByPassing Passwords when... 05-24-2010, 10:33 PM
Leith Ross Re: ByPassing Passwords when... 05-24-2010, 11:34 PM
jameztown Re: ByPassing Passwords when... 05-24-2010, 11:59 PM
Leith Ross Re: ByPassing Passwords when... 05-25-2010, 01:40 AM
jameztown Re: ByPassing Passwords when... 05-25-2010, 07:58 AM
Leith Ross Re: ByPassing Passwords when... 05-25-2010, 01:04 PM
jameztown Re: ByPassing Passwords when... 05-25-2010, 01:21 PM
jameztown Re: ByPassing Passwords when... 05-25-2010, 07:42 PM
Leith Ross Re: ByPassing Passwords when... 05-25-2010, 08:22 PM
jameztown Re: ByPassing Passwords when... 05-25-2010, 09:01 PM
Leith Ross Re: ByPassing Passwords when... 05-25-2010, 11:02 PM
jameztown Re: ByPassing Passwords when... 05-25-2010, 11:09 PM
Leith Ross Re: ByPassing Passwords when... 05-25-2010, 11:36 PM
jameztown Re: ByPassing Passwords when... 05-25-2010, 11:54 PM
Leith Ross Re: ByPassing Passwords when... 05-26-2010, 07:00 PM
jameztown Re: ByPassing Passwords when... 05-26-2010, 10:16 PM
jameztown Re: ByPassing Passwords when... 05-27-2010, 10:04 AM
Leith Ross Re: ByPassing Passwords when... 05-27-2010, 11:43 AM
jameztown Re: ByPassing Passwords when... 05-27-2010, 12:49 PM
jameztown Re: ByPassing Passwords when... 05-27-2010, 11:09 AM
  1. #1
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: ByPassing Passwords when pulling stats from external password-protected files

    Hello jameztown,

    Are you saying each workbook will have more than just the "Summary" sheet and the same columns will be used but the row will change? Will each workbook have the same number of sheets? Will each sheet use only a specific row like "Summary" is row 16, "First Quarter" is row 18, etc?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  2. #2
    Registered User
    Join Date
    05-24-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: ByPassing Passwords when pulling stats from external password-protected files

    Quote Originally Posted by Leith Ross View Post
    Hello jameztown,

    Are you saying each workbook will have more than just the "Summary" sheet and the same columns will be used but the row will change? Will each workbook have the same number of sheets? Will each sheet use only a specific row like "Summary" is row 16, "First Quarter" is row 18, etc?

    Hi Leith... yes; sorry. there is a summary sheet for each week of the year. all of the summary sheets are the same except they're pulling from the external sheet two lines below the previous week.

    All of the external workbooks are exactly the same; but with different stats. I've attached a new file showing this. I've also attached an example external sheet.

    Sorry! I'm confused; i thought I could take over from here as it seemed simple at first thought
    Attached Files Attached Files
    Last edited by jameztown; 05-25-2010 at 09:13 PM.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: ByPassing Passwords when pulling stats from external password-protected files

    Hello jameztown,

    You will need to upload the "craig_h_stats" again. It is protected and all my software says it isn't an Excel file - WTF???

  4. #4
    Registered User
    Join Date
    05-24-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: ByPassing Passwords when pulling stats from external password-protected files

    hmm.. okay; i've attached the file again. i've taken off the password too, just in case. thanks!

    i've trimmed down the external stat file. it goes until March 31st, 2011. So, I will be pulling stats weekly until that date in the current file that we've been working on.
    Attached Files Attached Files

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: ByPassing Passwords when pulling stats from external password-protected files

    Hello jameztown,

    Sweet, that opened with no problem. Nice layout on the "Summary" sheet. Is that your handy work?

  6. #6
    Registered User
    Join Date
    05-24-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: ByPassing Passwords when pulling stats from external password-protected files

    Quote Originally Posted by Leith Ross View Post
    Hello jameztown,

    Sweet, that opened with no problem. Nice layout on the "Summary" sheet. Is that your handy work?
    haha, yes. the files have gotten pretty complex over the past few years for me and I'm trying to do more with the stats for comparison and to make things easier for me. Until now, I haven't been using VBA. I'm trying to get some crash courses on here and elsewhere; but, there's an endless amount to learn, it seems

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: ByPassing Passwords when pulling stats from external password-protected files

    Hello jameztown,

    I ran the updated macro on using the files you sent and it worked fine on my end. Check it out and let me know how it goes. Here is the updated macro.
    'Written: May 24, 2010
    'Updated: May 26, 2010
    'Author:  Leith Ross
    
    Sub UpdateAll()
    
      Dim Cell As Range
      Dim Data() As Variant
      Dim Filename As String
      Dim Passwords As Object
      Dim R As Long
      Dim Rng As Range
      Dim RngEnd As Range
      Dim Wkb As Workbook
      Dim WkbName As String
      Dim WkbPath As String
      Dim WeekDate As String
      Dim WeekRng As Range
      
        If ActiveSheet.Name = "Passwords" Then
           MsgBox "You Can Not Run the Macro on this Worksheet."
           Exit Sub
        End If
        
        WeekDate = SheetNameToDate(ActiveSheet.Name)
        
        Set Rng = Range("A4")
        Set RngEnd = Cells(Rows.Count, Rng.Column).End(xlUp)
        
        If RngEnd.Row < Rng.Row Or Rng.Cells(1, 1) = "" Then
           MsgBox "There is no data on '" & ActiveSheet.Name & "'", vbOKOnly + vbExclamation
           Exit Sub
        Else
           Set Rng = Range(Rng, RngEnd)
        End If
          
        Application.ScreenUpdating = False
          
          WkbPath = ThisWorkbook.Path & "\"
          
          Set Passwords = CreateObject("Scripting.Dictionary")
          Passwords.CompareMode = vbTextCompare
          
          For Each Cell In Worksheets("Passwords").Range("A1").CurrentRegion.Columns(1).Cells
            If Not Passwords.Exists(Cell.Text) Then
               Passwords.Add Cell.Text, Cell.Offset(0, 1).Text
            End If
          Next Cell
          
          For Each Cell In Rng
            WkbName = Join(Split(Cell.Text, " "), "_") & "_stats.xls"
            Filename = WkbPath & WkbName
            On Error Resume Next
            Set Wkb = Workbooks.Open(Filename:=Filename, Password:=Passwords(WkbName))
            If Err = 1004 Then Err.Clear: GoTo NextWkb
              With Wkb.Worksheets("summary")
                Set WeekRng = .Range("A16")
                Set RngEnd = .Cells(Rows.Count, "A").End(xlUp).Offset(-1, 0)
                If RngEnd.Row <= WeekRng.Row Then GoTo NextWkb
                  For R = WeekRng.Row To RngEnd.Row
                    If StrComp(.Cells(R, "A").Text, WeekDate, vbTextCompare) = 0 Then
                      Data = Array(.Cells(R, "C").Value, .Cells(R, "D").Value, .Cells(R, "E").Value, _
                         .Cells(R, "F").Value, .Cells(R, "G").Value, .Cells(R, "H").Value, _
                         .Cells(R, "I").Value, .Cells(R, "J").Value, .Cells(R, "M").Value, _
                         .Cells(R, "N").Value, .Cells(R, "O").Value, .Cells(R, "Q").Value, _
                         .Cells(R, "R").Value, .Cells(R, "S").Value, .Cells(R, "T").Value, _
                         .Cells(R, "U").Value, .Cells(R, "V").Value, .Cells(R, "W").Value)
                    End If
                  Next R
              End With
            Wkb.Protect Password:=Passwords(WkbName)
            Wkb.Close SaveChanges:=True
            Cell.Offset(0, 2).Resize(1, UBound(Data) + 1).Value = Data
    NextWkb:
          Next Cell
          
        Set Passwords = Nothing
        Application.ScreenUpdating = True
        
    End Sub


    This is a New Macro that was added in Module2
    'Written: May 26, 2010
    'Author:  Leith Ross
    'Summary: Converts a sheet name like Mar27 into a date string like "27-mar-2010"
    
    Function SheetNameToDate(ByVal ShtName As String) As String
    
      Dim DateText As String
      Dim RegExp As Object
      
        Set RegExp = CreateObject("VBScript.RegExp")
        RegExp.IgnoreCase = True
        RegExp.Pattern = "([A-Za-z]{3})(\d{1,2})"
        
          If RegExp.Test(ShtName) = True Then
             DateText = RegExp.Replace(ShtName, "$2-$1-" & Format(Now(), "yy"))
          Else
             MsgBox "Could Not Convert Sheet Name '" & ShtName & "' to a Date."
          End If
        
        SheetNameToDate = DateText
        Set RegExp = Nothing
        
    End Function
    Attached Files Attached Files

+ 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