PC Review


Reply
Thread Tools Rate Thread

Close current workbook

 
 
Robert Crandal
Guest
Posts: n/a
 
      25th Dec 2009
I need some VBA code to tell my current workbook
to close itself. The problem is, my workbook will not
always have the same filename. Users may change the
names of their workbook files at any time, so I need
a way to close a workbook without referencing the
filename associated with a workbook.

Is this possible?

thank you


 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      25th Dec 2009
Joel,

If you use

ThisWorkbook.close

that would end execution of all macros in "ThisWorkbook."

Barb Reinhardt



"joel" wrote:

>
> The workbook with the macro is refered to as THISWORKBOOK. So you can
> use
>
> Thisworkbook.close savechanges:=True
> or
> Thisworkbook.close savechanges:=True
>
>
> This will leave the excel application running
>
> To close the application and the workbook first save the file then quit
> the application
>
>
> Thisworkbook.Save
> Thisworkbook.quit
>
>
> You can't close the application if you son't want to save the file.
>
>
> If you are referencing another workbook I always recommend giving all
> workbook a variable name on opening.
>
>
> set bk = workbooks.open(filename:="book1.xls")
>
> The using bk to close the workbooks
>
> bk.save
> bk.close savechanges:=true
> thisworkbook.quit
>
>
> --
> joel
> ------------------------------------------------------------------------
> joel's Profile: 229
> View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=165091
>
> Microsoft Office Help
>
> .
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to close a toolbar on exit of workbook - current code not work Tom Joseph Microsoft Excel Programming 10 23rd Feb 2009 01:58 AM
Open New Workbook / Save and Close Current Workbook Joe K. Microsoft Excel Programming 1 7th Dec 2007 08:04 PM
Close a the current workbook and load another specified workbook Adrian Microsoft Excel Programming 4 7th Aug 2004 05:29 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Microsoft Excel Programming 3 24th Jun 2004 12:50 PM
Close current Workbook after calling macro in other Des Janke Microsoft Excel Programming 4 7th Aug 2003 07:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:28 PM.