Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Application.StatusBar not refreshing after ThisWorkbook.Close | Excel Programming | |||
Call user form from ThisWorkbook; close file if form closed | Excel Programming | |||
Setting Application.EnableEvents=True after Thisworkbook.Close call | Excel Programming | |||
ThisWorkbook.close doesn't wokk :( | Excel Programming |