有什么方法可以编写代码(VBA),它可以在宏运行时确认您打开了一个未知的 Excel 文件???
我的目的是将未知 Excel 工作簿中的一些值复制到正在运行的宏上的值,但我不确定这是否可能。
代码的想法是这样的:
Sub test()
MSG1 = MsgBox("Do you want to copy the values?", vbYesNo, "OPEN")
If MSG1 = vbYes Then
MsgBox "Open the file you want to copy"
'Here is when the user has to open the file and the VBA
'acknowledge that and keep running the macro but only if the file is open
ThisWorkbook.Range("A1:B10").Value = _
Workbooks(Workbooks.Count).Range("A1:B10").Value
End If
End Sub
有什么想法吗。