-
I've been playing with this trying to reproduce the problem with some success, but not complete. Although I didn't get the same error message (that the file could only be opened read-only) Excel was still running). Occasionally I got the recovery pane up when I tried to view test.xls normally, but it had been saved properly.
The message you get implies that not only is Excel running, but also that the file is still open in it.
I note that you have
ActiveWorkbook.Save
then right up on the heels of that:
xlFile.Close True
I took out the Activeworkbook.Save and let the Close statement take care of saving and things got a lot cleaner. Excel closed down properly.
I realise that I'm not getting the same message as you but.. who knows?
Later, things got slicker when I made a few more changes taking out the .Visible=True and all the selecting and all ActiveCell/ActiveAnything references (note that I changed some textbox names etc. to suit my userform - and I hope I got the cell offsets right):
[vba]Dim xx As Excel.Range
'AppXL.Visible = True
Set xx = XLFile.Worksheets("Sheet1").Range("a65536").End(xlUp).Offset(1, 0)
If xx = "" Then 'it has to be! (because XlUp has just run over it)
xx.Value = TextBox1.Text
xx.Offset(0, 1).Value = TextBox2.Text
End If
'ActiveWorkbook.Save
XLFile.Close True
Set XLFile = Nothing
appXL.Quit
Set appXL = Nothing[/vba]
ps. If you're expecting others to use taskill on their machines I'd be scared it would kill all their instances of Excel!
Last edited by p45cal; 04-17-2010 at 08:33 AM.
p45cal
Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules