Solved

Force Excel workbook to close without need to save a copy

Posted on 2003-11-30
7
560 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:michelle_branch
Comment Utility
I
0
 

Author Comment

by:michelle_branch
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now