Solved

Force Excel workbook to close without need to save a copy

Posted on 2003-11-30
7
564 Views
Last Modified: 2010-05-03
Hi All..
i open an excel workbook using VB and modify some data in the excel sheet.
when i use command to close thhe workbook.. exel application will ask me whether i want to save the document or not..

How i want to force the excel workbook to close without i need to confirm whether i want to save it or not?
Meaning that, the excel will close without save a copy automatically when i click close button in my VB.

thanks a lot!!!!
0
Comment
Question by:michelle_branch
  • 4
  • 3
7 Comments
 
LVL 39

Accepted Solution

by:
appari earned 50 total points
ID: 9847604
just before closing the excel add this line.

if objExcel is your excel application object then

objExcel.DisplayAlerts = False
0
 

Author Comment

by:michelle_branch
ID: 9847682
can mr appari give more details? what u mean by this "if objExcel is your excel application object then
"?

sorryy.. i'm kindda slow.. :)
0
 
LVL 39

Expert Comment

by:appari
ID: 9848120
can you post your code.

>>"if objExcel is your excel application object then " i mean i am supposing the object name you are using in your program is "objExcel"
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:michelle_branch
ID: 9848156
I
0
 

Author Comment

by:michelle_branch
ID: 9848195
I put..

Dim myapp As New excel.Application  
Dim myWB As excel.Workbook  
Dim myWS As excel.Worksheet

Set myWB = myapp.Workbooks.Open("c:\Diode_Temp\Diodelog.xls")
Set myWS = myWB.Sheets(Diodelog)

Range("A1").Select
Selection.TextToColumns Destination:=Range("A1"), _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, _
Comma:=False, Space:=True, Other:=False, _
FieldInfo:=Array(Array(1, 1), Array(2, 1)), _
TrailingMinusNumbers:=True

Tm = myWS.Range("A1").Value
MsgBox Tm

myWB.Close      
Set myWB = Nothing
myapp.Quit  
Set myapp = Nothing


~something like this..
0
 
LVL 39

Expert Comment

by:appari
ID: 9848233
try this


Dim myapp As New excel.Application  
Dim myWB As excel.Workbook  
Dim myWS As excel.Worksheet

Set myWB = myapp.Workbooks.Open("c:\Diode_Temp\Diodelog.xls")
Set myWS = myWB.Sheets(Diodelog)

Range("A1").Select
Selection.TextToColumns Destination:=Range("A1"), _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, _
Comma:=False, Space:=True, Other:=False, _
FieldInfo:=Array(Array(1, 1), Array(2, 1)), _
TrailingMinusNumbers:=True

Tm = myWS.Range("A1").Value
MsgBox Tm

'*************** THIS IS ADDED BY ME
myapp.DisplayAlerts=false

myWB.Close      
Set myWB = Nothing
myapp.Quit  
Set myapp = Nothing


0
 

Author Comment

by:michelle_branch
ID: 9848237
now i got it..
i thought ur coding is "If..Then" statement.. that's why it didn't work.

now it works fine. thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question