0
我有以下代码和YesNoCancel
选项不会执行任何操作。请问我做错了什么?VBA YesNoCancel不按预期方式工作
Option Explicit
Sub wwb()
'lists each book that's OPEN
Dim wb As Workbook, ws As Workbook, wd As Workbook
Set wd = ThisWorkbook
MsgBox wd.Name
Dim output As Integer
Dim msgValue
For Each wb In Application.Workbooks
If wb.Name = wd.Name Then
MsgBox "The destination WorkBook is :" & wd.Name
Else
output = MsgBox("Is " & wb.Name & " your source file to import data?", vbYesNoCancel, "Please confirm source file")
If msgValue = vbYes Then
MsgBox "test yes"
ElseIf msgValue = vbNo Then
MsgBox "test No"
ElseIf msgValue = vbCancel Then
MsgBox "Test cancel"
End If
End If
Next wb
End Sub
您不必为'wb'一个'set'。谁是'wb'? – BOB
vb是所有打开的工作簿,并且只在for循环中存储临时名称,如下定义:For Each wb在Application.Workbooks –