我有以下代码,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
答案 0 :(得分:1)
您需要检查output
而不是msgValue
output = MsgBox("Is " & wb.Name & " your source file to import data?", vbYesNoCancel, "Please confirm source file")
If output = vbYes Then
MsgBox "test yes"
ElseIf output = vbNo Then
MsgBox "test No"
ElseIf output = vbCancel Then
MsgBox "Test cancel"
End If