Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default 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   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


  #3   Report Post  
Posted to microsoft.public.excel.programming
COM COM is offline
external usenet poster
 
Posts: 40
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default 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
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
CLASS MODULE & SIMPLE MODULE FARAZ QURESHI Excel Discussion (Misc queries) 1 September 7th 07 09:32 AM
code in module A to not execute a Worksheet_SelectionChange sub of another module Jack Sons Excel Discussion (Misc queries) 4 December 11th 05 11:52 PM
INserting a worksheet from one workbook to another workbook Billy New Users to Excel 1 June 1st 05 12:14 AM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM
Remove VB Module from workbook Nikos Yannacopoulos[_2_] Excel Programming 2 October 3rd 03 02:11 PM


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