Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy Worksheet with Code | Excel Programming | |||
How to copy a worksheet without its code ? | Excel Programming | |||
Copy Worksheet without VB code attached? | Excel Programming | |||
Code to copy range vs Copy Entire Worksheet - can't figure it out | Excel Programming | |||
Copy worksheet, code and all, into workbook? | Excel Programming |