View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robin Hammond Robin Hammond is offline
external usenet poster
 
Posts: 79
Default Closing a workbook without saving

Without being able to test this, I think the offending line should just be

ActiveWorkbook.Close(False)

as it is it is missing a colon and should not be a string in quotes.

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in


"Darrin Henry" wrote in message
...
Hello Guys,
I'm about to go crazy, I'm trying to get a workbook to close, after
all the tasks I need done are finished, without saving. Normally this is
easy, ActiveWorkbook.Close False. However, that is not working for me.

Here is the sequence of events that are completed before the workbook
needs to close(all this is invoked by a command button):

1) The workbook is saved with the filename as the contents of a cell.
2) Then the workbook is attached to an email and sent off to three
people at the same time, using SendMail.
3) Then an input box pops up, and using what the user puts into that
box, which is going to be an email address, the workbook is attached and
sent out a second time.
4)Then I need the workbook to close without saving the changes. But
whatever I do, nothing works. I've tried not displaying the
alerts(Application.DisplayAlerts False), and nothing works. Here is a
scaled down version of my code(edited for sensitive info):

Private Sub CommandButton1_Click()
Dim File
File = Dir("C:\" & Worksheets("sheet1").Range"F9").Value _ & ".xls")
MyFile = "" Then
ActiveWorkbook.SaveAs Filename:="C:\" & Worksheets
_("sheet1").Range("F9").Value & ".xls"
End If
Dim usename
usename = Application.UserName & "
End If
'ActiveWorkbook.SendMail Array ",
, usename)
Range("F43:J43") = "XXXX-XXXX-XXXX-XXXX"
Dim resp, cname
cname = Range("D12")
resp = InputBox("What is the customer's Email ?", _
"Customer Copy")
ActiveWorkbook.SendMail (resp)
ThisWorkbook.Saved = True
ActiveWorkbook.Close (SaveChanges = "False")
End Sub

Any ideas?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!