Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent! Close Excel worksheet in VB

Status
Not open for further replies.

tinymind

Programmer
Nov 9, 2000
90
GB
Hello All,

Simple really...

Problem: The problem lies in Excel 97 and what I want to do is code a button in a worksheet to close and not save the changes ...

Why: I know it is bad practice but I have a large amount of VB code that runs several Pivot, Imports, stats analysis etc etc ... you get the picture ...

Question: Can this be done?

TINY Perfection is Everything
If it worked first time we wont be here!
 
RTFM i Quess... :

Close Method


Closes the object. The Workbooks collection uses Syntax 1. Window and Workbook objects use Syntax 2.

Syntax 1

expression.Close

Syntax 2

expression.Close(SaveChanges, FileName, RouteWorkbook)

expression Required. An expression that returns an object in the Applies To list.

SaveChanges Optional Variant. If there are no changes to the workbook, this argument is ignored. If there are changes to the workbook and the workbook appears in other open windows, this argument is ignored. If there are changes to the workbook but the workbook doesn't appear in any other open windows, this argument specifies whether changes should be saved, as shown in the following table.

"In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963
 
I just figured it out ...

myBook.Close savechanges:=False

Cheers for your quick respoce ... DaOtH

Tiny Perfection is Everything
If it worked first time we wont be here!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top