View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
COM COM is offline
external usenet poster
 
Posts: 40
Default 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