I was able to open the excel file before and the copied sheet of a closed workbook would paste itself into the opened workbook, deleting the sheet that was titled "SEEBREZ IMS.1". But now when I open the excel file it wont run my vba code, it works efficiently if I manually run the code.
Sub WorkbookOpen_CopyandReplace()
'It will check to see if there is a worksheet wit the same name and delete it
'On Error GoTo 0 then excutes the next line of code that will allow us to enter in a workbook, with it being closed, and copy that worksheet in this workbook
Application.ScreenUpdating = False
On Error Resume Next
ThisWorkbook.Sheets("SEEBREZ IMS.1").Delete
On Error GoTo 0
Set closedBook = Workbooks.Open("P:\62001-5 IN PROCESS\DDE 62001-5\62001-5 4141-84 SEEBREZ SEAT_IMS.xls")
closedBook.Sheets("SEEBREZ IMS.1").Copy Before:=ThisWorkbook.Sheets("IMS.1")
closedBook.Close SaveChanges:=False
Application.ScreenUpdating = True
End Sub
A Workbook Open: Import Worksheet From Closed Workbook
ThisWorkbookModuleThisWorkbookmodule and as indicated by Tim Williams in the comments, you cannot change its signature. This is an event code and it will run when something happens, in this case, each time the workbook is opened. There are many other events forThisWorkbookand even more so for each sheet.Standard Module e.g.
Module1ImportSEEBREZfrom anywhere.ThisWorkbookmodule with the event code. If additionally, you don't want it to be seen in the Macro dialog, you can make it private (Private Sub...).