![]() |
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. |
ActiveSheet.Copy
After you copy the active sheet you will have created a new work book
containing the copied sheet. The ActiveSheet is still the original worksheet. I suggest that you create a new workbook.worksheet object that refers to the new workbook, and use that as a reference to in your code where necessary, rather than ActiveSheet --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 10:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com