如何
1.从当前(FIRST.XLSM)工作簿运行宏以打开另一个工作簿(SECOND.XLSM)
2.在关闭(FIRST.XLSM)的(SECOND.XLSM)工作簿上运行宏,然后继续其过程
我试过这个:
Sub FirstMacro()
Workbooks.Open Range("f90") 'second workbook full path
Workbooks("first.XLSM").Close SaveChanges:=True 'save first workbook and close
Second_Workbook_Macro ' run second workbook macro
End Sub
但是由于它保存并关闭了第一个工作簿,因此vba不会继续其程序..
答案 0 :(得分:1)
Sub FirstMacro()
Dim wb As Workbook
Set wb = Workbooks.Open Range("f90") 'second workbook full path
Application.Run "'" & wb.Name & "'!Second_Workbook_Macro"
ThisWorkbook.Close SaveChanges:=True 'save first workbook and close
End Sub