Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
name of the activesheet rasta Excel Programming 1 October 3rd 03 09:49 PM
How to copy text from a TextBox in a ActiveSheet to a variable Tom Ogilvy Excel Programming 2 August 19th 03 06:35 PM
How to copy text from a TextBox in a ActiveSheet to a variable pat Excel Programming 0 August 19th 03 05:06 PM
ActiveSheet.Name? Andrew Stedman Excel Programming 5 July 30th 03 01:17 PM
ActiveSheet Ron de Bruin Excel Programming 0 July 29th 03 04:59 PM


All times are GMT +1. The time now is 06:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"