![]() |
ThisWorkbook.Close question
Please take a look at the code below:
Public Sub DumbFoo ( ) ThisWorkbook.Close() Sheet1.Range("A1").Value = -1 ThisWorkbook.Save() End Sub Is it safe to assume that the code below the "ThisWorkbook.Close()" line will NOT be executed??? My question is basically: Does all VBA code stop executing once a .Close() function is called??? Thank you! |
ThisWorkbook.Close question
I don't believe the code would execute at all because of the parentheses
after Close. It would throw an error an tell you that something is missing, or type mismatch. But, if you did have the correct syntax, without the parentheses, then the workbook would close and no further sheet activity would be processed and the workbook would not be saved, but you would probably get a message asking you if you want to save the workbook. Be careful where you put the parentheses in VBA. They usually indicate that something is needed to complete the command or modify the object. If that something is not included in the parentheses it throws an error. See "Using Parentheses in Code" in the VBA help files for more details. "Robert Crandal" wrote in message ... Please take a look at the code below: Public Sub DumbFoo ( ) ThisWorkbook.Close() Sheet1.Range("A1").Value = -1 ThisWorkbook.Save() End Sub Is it safe to assume that the code below the "ThisWorkbook.Close()" line will NOT be executed??? My question is basically: Does all VBA code stop executing once a .Close() function is called??? Thank you! |
ThisWorkbook.Close question
Yes, try Public Sub DumbFoo ( ) Sheet1.Range("A1").Value = -1 ThisWorkbook.Close SaveChanges:=true End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Robert Crandal" wrote in message ... Please take a look at the code below: Public Sub DumbFoo ( ) ThisWorkbook.Close() Sheet1.Range("A1").Value = -1 ThisWorkbook.Save() End Sub Is it safe to assume that the code below the "ThisWorkbook.Close()" line will NOT be executed??? My question is basically: Does all VBA code stop executing once a .Close() function is called??? Thank you! |
All times are GMT +1. The time now is 12:21 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com