Link to home
Start Free TrialLog in
Avatar of michelle_branch
michelle_branch

asked on

Force Excel workbook to close without need to save a copy

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!!!!
ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of michelle_branch
michelle_branch

ASKER

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

sorryy.. i'm kindda slow.. :)
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"
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..
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


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

now it works fine. thanks