Solved

Force Excel workbook to close without need to save a copy

Posted on 2003-11-30
7
562 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA color chart bars 12 76
Macro which automatically send Excel spreadsheet to Outlook problem 2 59
Validating VB6 Function 19 56
Windows 10 start screen issues 9 51
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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

932 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

12 Experts available now in Live!

Get 1:1 Help Now