Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default 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!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default 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!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.StatusBar not refreshing after ThisWorkbook.Close LEO@KCC Excel Programming 6 September 12th 07 10:41 AM
Call user form from ThisWorkbook; close file if form closed XP Excel Programming 2 July 20th 07 07:04 PM
Setting Application.EnableEvents=True after Thisworkbook.Close call John Fuller Excel Programming 3 September 4th 06 02:50 PM
ThisWorkbook.close doesn't wokk :( Arnaud.L Excel Programming 9 April 1st 04 08:46 AM


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"