我有一个工作簿表,它从另一个工作簿中运行一个宏。功能运行正常。但是具有宏(从活动工作表运行)的工作簿会打开并且不会通过vba关闭。我必须手动关闭它。我该怎么做才能让它靠近代码本身,以便其他文件保持打开状态
代码如下:
Sub UpdateStockRegister()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Run "'F:\ITEMS.xlsm'!UniqueTransactionItems"
ActiveWorkbook.Close
Dim wbSource As Workbook
Dim wbTarget As Workbook
Set wbTarget = ThisWorkbook
Set wbSource = Workbooks.Open("F:\ITEM REPORT.xlsm")
wbSource.Sheets("TRANSACTION DATA").Copy After:=wbTarget.Sheets("STOCK REGISTER")
wbSource.Close Savechanges = True
Sheets("TRANSACTION DATA").Select
ActiveSheet.Range("A1").EntireRow.Delete
Range("A1").Select
Sheets("TRANSACTION DATA").Select
ActiveSheet.Range("A1").EntireRow.Delete
Range("A1:A15000,B1:B15000,C1:C15000,D1:D15000,E1:E15000,F1:F15000").Select
Selection.Copy
Sheets("STOCK REGISTER").Select
Range("A8").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.HorizontalAlignment = xlCenter
Selection.VerticalAlignment = xlCenter
Range("A8").Select
Sheets("TRANSACTION DATA").Delete
ActiveWorkbook.Save
End Sub