I have wb1 and wb2. wb1 is used for data entry and wb2 is used to record that data. wb2 is password protected (let's say with "password"). The VBA below is in wb1 and is run on a button click. As it is now, a box pops up requesting the password for wb2 before the VBA is done running. Is there a way to use VBA to enter "password" in that box? I'm fairly new to VBA, so I'm open to other suggestions as well. Thanks!
Sub OpenClose() Application.ScreenUpdating = False Dim wb1 As Workbook Dim wb2 As Workbook Set wb1 = ThisWorkbook Set wb2 = Workbooks.Open("C:\Users. ") 'I have taken out the rest of the file path wb1.Activate Sheets("Entry").Activate Range("A1:A5").Select Selection.Copy wb2.Activate Sheets("Log").Activate Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=True wb2.Save wb2.Close Set wb1 = Nothing Set wb2 = Nothing MsgBox "Logged and saved." Application.ScreenUpdating = True End Sub
27.2k 5 5 gold badges 40 40 silver badges 74 74 bronze badges
asked Dec 3, 2015 at 19:28
user5472539 user5472539
Take a look at the WorkBook.Unprotect method. Here's the MSDN for it: msdn.microsoft.com/en-us/library/office/ff196695.aspx