Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copy VB code from one worksheet to another using VBE

I would like to know how to transfer code from one worksheet to another using
VBE and the password protect the second worksheet. I would like to all of
this using VB code in Excel!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Copy VB code from one worksheet to another using VBE

Hi
Since you would only want to automate this if you have to do it lots of
times, why not create an Excel Add-In instead. This will separate your
code from the worksheets. If you need to update the code (and you will)
then you do it in the Add-In once and redistribute it, rather than
changing the code in lots of worksheets.
Add-In's are easy to do. You simply write code as normal in a workbook,
and use the Auto_Open and Close subs to create and delete a menu bar
for you so that you can apply your code to the active workbook. You
then set the Is Add-In? property of the workbook to true and that is
pretty much it.
Post back if this sounds like what you want and you want a bit more
detail.
regards
Paul

eDude wrote:
I would like to know how to transfer code from one worksheet to another using
VBE and the password protect the second worksheet. I would like to all of
this using VB code in Excel!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copy VB code from one worksheet to another using VBE

Dear Paul,

The purpose of my coping code is that there is a Master Sheet - A Tool that
creates tests (exams)". When the appropriate selections are made and I tell
the tool to create for eg: 10 tests, then tool creates 10 Random User IDs &
passwords along with file names and assigns to the 10 new workbooks. To these
10 new workbooks is where I would like to pass the code so the test features
get activated!

I have tried the below code found on the net, but it gives me an error that
"VB cannot trust to handover control..." or something like that!!!

Sub CopyOneModule()
Dim FName As String
With Workbooks("Book2")
FName = .Path & "\code.txt"
.VBProject.VBComponents("Module1").Export FName
End With
Workbooks("book1").VBProject.VBComponents.Import FName
End Sub

If you can help me with this, that would be great.

Regards,
Mahesh

" wrote:

Hi
Since you would only want to automate this if you have to do it lots of
times, why not create an Excel Add-In instead. This will separate your
code from the worksheets. If you need to update the code (and you will)
then you do it in the Add-In once and redistribute it, rather than
changing the code in lots of worksheets.
Add-In's are easy to do. You simply write code as normal in a workbook,
and use the Auto_Open and Close subs to create and delete a menu bar
for you so that you can apply your code to the active workbook. You
then set the Is Add-In? property of the workbook to true and that is
pretty much it.
Post back if this sounds like what you want and you want a bit more
detail.
regards
Paul

eDude wrote:
I would like to know how to transfer code from one worksheet to another using
VBE and the password protect the second worksheet. I would like to all of
this using VB code in Excel!



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 Worksheet with Code Bill[_30_] Excel Programming 1 September 28th 05 10:21 PM
How to copy a worksheet without its code ? PM Excel Programming 1 November 16th 04 04:20 PM
Copy Worksheet without VB code attached? Chris McFarland Excel Programming 0 June 23rd 04 07:54 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
Copy worksheet, code and all, into workbook? Ed[_9_] Excel Programming 2 September 22nd 03 03:11 PM


All times are GMT +1. The time now is 03:17 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"