Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting Module into Workbook
Hi,
I have an application that creates a summary workbook on the fly, every time the uses presses the 'summary build' button the workbook is overwritten. I would like to be able to include in the summary workbook some macros that can be used in isolation of the application. What is the best route to achieving this? I had thought of creating the module in the application and somehow copying this into the summary workbook, but I am not sure what the code is to do this. TIA Nigel ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting Module into Workbook
I'm "reposting" this information. Something similar came up "yesterday".. If you look at the threads that started 12/28/2003 and look for Bloodhound.ExcelMacro as the title, you can follow a thread that discusses "copying" the VB code you wish to copy... Yes I am simply copying the "last" post, without modifications, hopefully you can work out the details from what is posted. See the bottom of this message for the previously posted text that is described above. ----- Nigel wrote: ----- Hi, I have an application that creates a summary workbook on the fly, every time the uses presses the 'summary build' button the workbook is overwritten. I would like to be able to include in the summary workbook some macros that can be used in isolation of the application. What is the best route to achieving this? I had thought of creating the module in the application and somehow copying this into the summary workbook, but I am not sure what the code is to do this. TIA Nigel ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- typo, that should be: Sub CopyMod() Dim Fname As String With Workbooks("VBA Code Examples.xls") Fname = .Path & "\code.txt" .VBProject.VBComponents("Module2").Export Fname End With Application.Run "imprt", Fname End Sub Function imprt(ByVal strfile As String) Workbooks("book2.xls").VBProject.VBComponents.Impo rt strfile End Function "Tim Zych" wrote in message ... Try this workaround: Sub CopyMod() Dim Fname As String With With Workbooks("VBA Code Examples.xls") Fname = .Path & "\code.txt" .VBProject.VBComponents("Module2").Export Fname End With Application.Run "imprt", Fname End Sub Function imprt(ByVal strfile As String) Workbooks("book2.xls").VBProject.VBComponents.Impo rt strfile End Function "Todd Huttenstine" wrote in message ... Hey guys, I am using the following code: The code simply exports the VBA code and module name of a specified module to a text file called code.txt and then saves it in the directory of the source workbook. It then imports that code and module name into another specified workbook. Dim FName As String With Workbooks("VBA Code Examples.xls") FName = .Path & "\code.txt" .VBProject.VBComponents("Module2").Export FName End With Workbooks("book2").VBProject.VBComponents.Import FName Nortan Anti virus is detecting this as the Bloodhound.ExcelMacro virus and will not allow me to save the file. How do I work around this? Thanx Todd Huttenstine |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting Module into Workbook
As for best route, (Sorry didn't answer in my previous response) in my limited experience of copying code from one workbook to another, I would have the code obviously already written in your "source" workbook. Then when the summary workbook is created, to copy the code over to the summary workbook where/however you would like it.
One thing I'm not sure about, is if you can use the method that was described to copy the code for ThisWorkbook... I had personnally found a different way around this in a program I wrote a few years ago, but it was/is rather complicated... Probably I made it more so than was necessary, but it worked. :) |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting Module into Workbook
You could export the module to a text file, then import it to the new workbook
(or just keep the text file available all the time and just import it when you need it). But even simpler may be to create a template file that contains all your code (and maybe all the formatting that you need). Then just use that to create the summary workbook. You could even just add a Open the template and move the worksheets to that template if you don't want to modify your existing code too much. (And the nice thing about this is you can keep the template's project locked so no one can modify your code.) Nigel wrote: Hi, I have an application that creates a summary workbook on the fly, every time the uses presses the 'summary build' button the workbook is overwritten. I would like to be able to include in the summary workbook some macros that can be used in isolation of the application. What is the best route to achieving this? I had thought of creating the module in the application and somehow copying this into the summary workbook, but I am not sure what the code is to do this. TIA Nigel ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Inserting Module into Workbook
Many thanks, templates seems to be the best route. I'm trying to set
something up now. Cheers Nigel "Dave Peterson" wrote in message ... You could export the module to a text file, then import it to the new workbook (or just keep the text file available all the time and just import it when you need it). But even simpler may be to create a template file that contains all your code (and maybe all the formatting that you need). Then just use that to create the summary workbook. You could even just add a Open the template and move the worksheets to that template if you don't want to modify your existing code too much. (And the nice thing about this is you can keep the template's project locked so no one can modify your code.) Nigel wrote: Hi, I have an application that creates a summary workbook on the fly, every time the uses presses the 'summary build' button the workbook is overwritten. I would like to be able to include in the summary workbook some macros that can be used in isolation of the application. What is the best route to achieving this? I had thought of creating the module in the application and somehow copying this into the summary workbook, but I am not sure what the code is to do this. TIA Nigel ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- -- Dave Peterson ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
CLASS MODULE & SIMPLE MODULE | Excel Discussion (Misc queries) | |||
code in module A to not execute a Worksheet_SelectionChange sub of another module | Excel Discussion (Misc queries) | |||
INserting a worksheet from one workbook to another workbook | New Users to Excel | |||
Variable from a sheet module in a class module in XL XP | Excel Programming | |||
Remove VB Module from workbook | Excel Programming |