Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problem copying worksheet containing code module

I have a very large workbook containing lots of VBA code.
Among other things, it has to copy one of its own
worksheets to a new workbook and save it. The sheet to be
copied has an associated coe module. The code is something
like this:

Sheet.Copy
set NewWorkbook = ActiveWorkbook

or

set NewWorkbook = Workbooks.Add
Sheet.Copy Befo=NewWorkbook.Sheets(1)

My code then references the newly-copied sheet to make
some changes to it.

This used to work fine, until recently when I replaced a
number of controls on worksheets with their ActiveX
equivalents. At some point (I don't know exactly when)
the above code ceased working correctly and started giving
an "Application or object defined" error. I could find no
way to get round it, so eventually I reverted to the
version prior to the ActiveX changes. The error persisted.

I have tried to circumvent this in various ways, but have
had no success. Eventually I tried the workbook on
another computer (running Windows 2000 Professional and
Office 2000, like the first), and it worked correctly.

It seems like something has become corrupted on the first
machine and maybe it is related to ActiveX controls. Does
anybody have any ideas?

I have tried re-installing Office but no luck (I even re-
tried reinstalling it after deleting the Office folder in
Program Files\Microsoft Office).

By the way, if I save this workbook on machine A (where
the other problem occurs) the file is much larger than
when I save it on machine B.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problem copying worksheet containing code module

Clarifications:

I have corrected a couple of errors in my original post,
so please look at the version following. Changes are in
upper case.

-----Revised Original Message-----

I have a very large workbook containing lots of VBA code.
Among other things, it has to copy one of its own
worksheets to a new workbook and save it. The sheet to be
copied has an associated CODE module.

The code THAT COPIES THE WORKSHEET is something
like this:

Sheet.Copy
set NewWorkbook = ActiveWorkbook

or

set NewWorkbook = Workbooks.Add
Sheet.Copy Befo=NewWorkbook.Sheets(1)

My code then references the newly-copied sheet to make
some changes to it.

This used to work fine, until recently when I replaced a
number of controls on worksheets with their ActiveX
equivalents. At some point (I don't know exactly when)
the above code ceased working correctly and started giving
an "Application or object defined" error WHENEVER I TRY TO
REFERENCE THE NEWLY-COPIED SHEET (FOR EXAMPLE, SOMETHING
AS SIMPLE AS SELECTING A CELL IN IT). I could find no
way to get round it, so eventually I reverted to the
version prior to the ActiveX changes. The error persisted.

I have tried to circumvent this in various ways, but have
had no success. Eventually I tried the workbook on
another computer (running Windows 2000 Professional and
Office 2000, like the first), and it worked correctly.

It seems like something has become corrupted on the first
machine and maybe it is related to ActiveX controls. Does
anybody have any ideas?

I have tried re-installing Office but no luck (I even re-
tried reinstalling it after deleting the Office folder in
Program Files\Microsoft Office).

By the way, if I save this workbook on machine A (where
the other problem occurs) the file is much larger than
when I save it on machine B.

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
code won't run from a module Geoff Excel Discussion (Misc queries) 3 February 20th 07 08:08 PM
Unprotect Code Module in Code Damien Excel Discussion (Misc queries) 2 April 18th 06 03:10 PM
Where?Worksheet code module or Worksheet_SelectionChange event han Kenzie Excel Worksheet Functions 4 January 30th 06 09:41 PM
code in module A to not execute a Worksheet_SelectionChange sub of another module Jack Sons Excel Discussion (Misc queries) 4 December 11th 05 11:52 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM


All times are GMT +1. The time now is 05:23 AM.

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"