Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Leave 2 macros after copy

David wrote

Simple solution. Many thanks. I may use it in the future.

Actually, a lightbulb lit when I realized that since I used the line:
ActiveWorkbook.Sheets.Copy
instead of
ActiveWorkbook.Copy
none of the modules or forms were copied to the new book anyway, so I
didn't need to delete anything since I had no sheet level code.

So I looked at Chip Pearson's .vbe page and used his method of copying a
module after putting the desired routines in the separate Module2:

With ThisWorkbook
FName = .Path & "\code.txt"
.VBProject.VBComponents("Module2").Export FName
End With
ActiveWorkbook.VBProject.VBComponents.Import FName
Kill FName


I shouldn't have said "instead of ActiveWorkbook.Copy", since you can't do
that anyway. What I should have said is:

Since there is no sheetlevel code and ActiveWorkbook.Sheets.Copy doesn't
copy any modules/forms, there is nothing to delete anyway, so I could do
away with all that VBComp stuff and replace it with the Module copy code.


--
David
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
Copy Sheet #'s, but leave cell reference KennyD Excel Discussion (Misc queries) 3 November 9th 09 10:55 PM
Macros: can you copy macros from one doc to another? Roady Excel Discussion (Misc queries) 1 June 12th 08 05:47 PM
using IF function to copy, but leave populated cell alone [email protected] Excel Worksheet Functions 5 May 12th 06 10:39 PM
How to copy paste from Excel and leave the pasted data editable? Cropduster Excel Worksheet Functions 3 June 11th 05 10:03 AM
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM


All times are GMT +1. The time now is 11:06 AM.

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

About Us

"It's about Microsoft Excel"