HELP! Macro stuck-"Invalid Object"

E

Ed

I walked this through the recorder yesterday using two documents and it
worked fine. I put it into a major macro routine and made some minor
changes - and now it hangs! But it hangs where yesterday it worked fine!

Workbooks.Open Filename:="C:\NWACCESS\DATA\Sent Updates\Warning.xls"
Cells.Select
Selection.Copy
With wb3.Sheets(3)
Cells.Select
ActiveSheet.Paste
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End With
Application.DisplayAlerts = FalseUpdates\Warning.xls"
Workbook.Close
Application.DisplayAlerts = True
declared at the beginning and has been used all throughout this routine -
and that isn't the problem. Somehow, I can't call back the first workbook
("Warning.xls") to close it. It's hung up saying "Invalid Object". I did
have Workbooks.Close Filename:=etc, but it didn't go, so I tried what's in
there now. It doesn't work either.

Any help?

Ed
 
H

Henry

Ed,

Try:
Workbooks("Warning.xls").Activate
ActiveWorkbook.Close

Or better still:
Workbooks("Warning.xls").Close
(there's no need to activate a workbook before closing it)

HTH
Henry
 

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