小编Ste*_*son的帖子

ThisWorkbook.ChangeFileAccess xlReadWrite在VBA窗口中为工作簿创建多个VBAProjects

我的工作簿有以下公开活动:

Private Sub Workbook_Open()
    ThisWorkbook.ChangeFileAccess xlReadOnly
End Sub
Run Code Online (Sandbox Code Playgroud)

然后这个按钮:

Sub UnlockDeveloper()
Dim pwd As String

pwd = InputBox("Enter developer password:", "Password")

If pwd = "password" Then
    If ThisWorkbook.ReadOnly = True Then
        ThisWorkbook.ChangeFileAccess xlReadWrite
    End If
Else
    MsgBox ("Incorrect password.")
End If

End Sub
Run Code Online (Sandbox Code Playgroud)

这通常很好,但有时运行UnlockDeveloper子会导致VBAProject在VBA窗口中出现两次,我无法知道哪个是真实文件.如果我在错误的位置进行更改,则只要关闭Excel,更改就会丢失.

截图

有人有任何想法如何防止这种情况?

excel vba excel-vba excel-2010 vbe

6
推荐指数
1
解决办法
2151
查看次数

标签 统计

excel ×1

excel-2010 ×1

excel-vba ×1

vba ×1

vbe ×1