ActiveWorkbook.Close (False)

  • Thread starter stefan via OfficeKB.com
  • Start date
S

stefan via OfficeKB.com

Hi,
Excel - shut down.
When i remove the line
ActiveWorkbook.Close True (or False)
from my code, i do not get the error. I can close the file manually and i can
close Excel manually.
With the line of code, the macro runs, saves the workbook, gives the
completion message box, and generates the Excel error. Shutting Excel down.
It states it creates an error log. I have no clue where to look for that log.

Strange thing is that i tested this under Win and Excel XP at home and it
worked like a charm.

Thank you for your help.

Stefan
----------------------
Sub Save_1_From_User_1()
'On Error Resume Next
Dim strdate As String
strdate = Format(Now, "dd-mmm-yy -- hh-mm-ss -- ")
Application.ScreenUpdating = False
' Mark to activate macro for user 2
Range("A1").Select
ActiveCell.FormulaR1C1 = "x"
' Copy/paste User Name formula to text only
Range("UserNameRange").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues
' Save the service form to location 1
' ActiveWorkbook.SaveAs "serviceformcopy.xls" ' Test Location/name 1
ActiveWorkbook.SaveAs "L:\Consultant service\Returns\Service_Forms\" &
"ID " & Sheets("Service Form").Range("C9") _
& " -- " & strdate & " from " & UserName & ".xls"
Application.ScreenUpdating = True
' Completion message and close of workbook
MsgBox "Submitted Successfully. - Thank you.", vbInformation, "Submission
Notice"
ActiveWorkbook.Close (False) '<= problem child
End Sub
 
D

Dave Peterson

Look for something like: drwtsn32.log or drwatson.log

But once you find it, I bet it won't help.

If it fails on that line (which looks ok to me), maybe you can try the code in a
test workbook.

Could it be that there's somekind of corruption happening with that workbook?
 
S

stefan via OfficeKB.com

Hi Dave,
First a correction.
Although the code worked under win XP Excel 2003 last night, it no longer
works and errors when the said line is in and does not error when the line is
not in.

Next. I never thought about taking that bit of code and run it in a different
workbook. Which i did with your recommendation.
This worked. No error and the workbook closed.
I'm lost...not that that wouldnt be easy anyway.
So i guess the error, although it happens or not with that specified line,
must come from something else.
How can i go about getting this fixed?
If i could i'd love to post my workbook if that would help you (someone) to
figure this out.

Thank you for your suggestion.

Stefan


Dave said:
Look for something like: drwtsn32.log or drwatson.log

But once you find it, I bet it won't help.

If it fails on that line (which looks ok to me), maybe you can try the code in a
test workbook.

Could it be that there's somekind of corruption happening with that workbook?
Hi,
Excel - shut down.
[quoted text clipped - 36 lines]
ActiveWorkbook.Close (False) '<= problem child
End Sub
 
D

Dave Peterson

My guess is since the code worked in a new workbook, it's not the code.

I think the problem may be in the workbook itself. I think I'd try recreating
that workbook.

stefan via OfficeKB.com said:
Hi Dave,
First a correction.
Although the code worked under win XP Excel 2003 last night, it no longer
works and errors when the said line is in and does not error when the line is
not in.

Next. I never thought about taking that bit of code and run it in a different
workbook. Which i did with your recommendation.
This worked. No error and the workbook closed.
I'm lost...not that that wouldnt be easy anyway.
So i guess the error, although it happens or not with that specified line,
must come from something else.
How can i go about getting this fixed?
If i could i'd love to post my workbook if that would help you (someone) to
figure this out.

Thank you for your suggestion.

Stefan

Dave said:
Look for something like: drwtsn32.log or drwatson.log

But once you find it, I bet it won't help.

If it fails on that line (which looks ok to me), maybe you can try the code in a
test workbook.

Could it be that there's somekind of corruption happening with that workbook?
Hi,
Excel - shut down.
[quoted text clipped - 36 lines]
ActiveWorkbook.Close (False) '<= problem child
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top