View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bill Oertell[_2_] Bill Oertell[_2_] is offline
external usenet poster
 
Posts: 18
Default ActiveSheet.Copy

This is the code I'm having problems with:

ActiveSheet.Copy
ActiveSheet.Unprotect
Columns("B:L").Select
Selection.EntireColumn.Hidden = False
Selection.Delete Shift:=xlToLeft
ActiveWorkbook.SaveAs "TSC-GPS " & ThisWorkbook.Name
ActiveWorkbook.SendMail Recipients:=Email(m),
Subject:=ActiveWorkbook.Name, ReturnReceipt:=True
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close False

The problem I'm having is that Unprotect seems to act on the old sheet, not the
new one that ActiveSheet.Copy creates. When this code runs I get a run time
error at the forth line. I can't remember the exact error message, but it's
obviously related to the sheet it's working on still being protected. I've run
the code with a break point on the first line (this is actually a small part of
a whole sub), and examined its effects. The original sheet is definitely
unprotected, while the new sheet is not. Suggestions are welcome. Oh...what
I'm trying to do is delete some columns that the recipients just don't need, and
if they got that info, it would only confuse them.
Thanks.