我有wb1和wb2.wb1用于数据输入,wb2用于记录该数据.wb2受密码保护(假设用"密码").
下面的VBA是wb1,按下按钮即可运行.就像现在一样,在VBA运行完毕之前弹出一个请求wb2密码的框.有没有办法使用VBA在该框中输入"密码"?
我对VBA很新,所以我也对其他建议持开放态度.谢谢!
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
Graham.. 11
打开时,wb2
将"password"参数作为Password
参数传递:
Set wb2 = Workbooks.Open(Filename:="C:\Users...", Password:="password")
有关详细信息,请参阅Workbooks.Open方法(Excel).
打开时,wb2
将"password"参数作为Password
参数传递:
Set wb2 = Workbooks.Open(Filename:="C:\Users...", Password:="password")
有关详细信息,请参阅Workbooks.Open方法(Excel).