Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Cascading macros to new workbooks

I have a spreadsheet which I am using as a master document from which I want
to generate many copies of a single worksheet (I only want that particular
worksheet to appear in the copies, not all three worksheets that exist in the
master). The master spreadsheet contains a workbook_open macro which I would
like to include in all the copies.

I am using the sheets(sheetname).copy function to create a clone of the
master worksheet but the workbook_open macro is not getting copied across.
The worksheet also has a number of buttons and all these macros are going
across just fine.

Is it possible to copy the workbook_open macro across in this way? If not
how can I programmatically create a workbook_open macro in the new workbooks?

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 341
Default Cascading macros to new workbooks

The workbook_open macro does not get copied because you are only copying the
sheets, not workbooks. The buttons work because they belong in the sheets.

To get around this, instead of copying the sheets that you need, you could
try copying the whole book, then removing the sheets that you DON'T need.
That's the easy way.

The hard way (see under creating an Event procedure)
http://www.cpearson.com/excel/vbe.htm

--
Allllen


"Phil N Dank" wrote:

I have a spreadsheet which I am using as a master document from which I want
to generate many copies of a single worksheet (I only want that particular
worksheet to appear in the copies, not all three worksheets that exist in the
master). The master spreadsheet contains a workbook_open macro which I would
like to include in all the copies.

I am using the sheets(sheetname).copy function to create a clone of the
master worksheet but the workbook_open macro is not getting copied across.
The worksheet also has a number of buttons and all these macros are going
across just fine.

Is it possible to copy the workbook_open macro across in this way? If not
how can I programmatically create a workbook_open macro in the new workbooks?

Thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Cascading macros to new workbooks

Thanks Allllen, very useful references. Unfortunately due to my current level
of skill I wasn't able to make very much progress with either solution :-(
Copying the workbook worked fine in terms of getting the macro across but I
lost context on the master sheet so I couldn't work my way down the cell
range I was using to drive the copies. Anyway I took a look at the
information in the link and it made me rethink what I am actually trying to
achieve and whether there is a simpler, more streamlined approach.

With hindsight, if I can hold the macro in a separate file and copy it in to
the generated sheet then I will achieve my objective and simplify the master
sheet (where the initial macro is not strictly necessary). However when I
copy the exported macro into the generated sheet (from the *.cls file, using
ActiveWorkbook.VBProject.VBComponents.Import) it stores it as a separate
'class' object and it is not run when the workbook opens. Is there a simple
way round this or am I barking up the wrong tree?

Thanks again

"Allllen" wrote:

The workbook_open macro does not get copied because you are only copying the
sheets, not workbooks. The buttons work because they belong in the sheets.

To get around this, instead of copying the sheets that you need, you could
try copying the whole book, then removing the sheets that you DON'T need.
That's the easy way.

The hard way (see under creating an Event procedure)
http://www.cpearson.com/excel/vbe.htm

--
Allllen


"Phil N Dank" wrote:

I have a spreadsheet which I am using as a master document from which I want
to generate many copies of a single worksheet (I only want that particular
worksheet to appear in the copies, not all three worksheets that exist in the
master). The master spreadsheet contains a workbook_open macro which I would
like to include in all the copies.

I am using the sheets(sheetname).copy function to create a clone of the
master worksheet but the workbook_open macro is not getting copied across.
The worksheet also has a number of buttons and all these macros are going
across just fine.

Is it possible to copy the workbook_open macro across in this way? If not
how can I programmatically create a workbook_open macro in the new workbooks?

Thanks in advance

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Cascading macros to new workbooks

I now have this working Alllen thanks to the very helpful stuff in your guide
on creating an event procedure. I have put the required 'workbook open' code
in a string within the body of the creating macro and it is added to the
'slave' workbooks just prior to the save. The other problem I encountered was
that I wanted to have the workbook protected (to stop curious users
viewing/changing things theydon't need to see) but this prevented the
'workbook open' macro making any changes to the dropdown lists! Doh! For the
moment I have taken the protection off but I will keep looking.

Thanks again for sharing your knowledge and making the community a very
useful resource.

"Phil N Dank" wrote:

Thanks Allllen, very useful references. Unfortunately due to my current level
of skill I wasn't able to make very much progress with either solution :-(
Copying the workbook worked fine in terms of getting the macro across but I
lost context on the master sheet so I couldn't work my way down the cell
range I was using to drive the copies. Anyway I took a look at the
information in the link and it made me rethink what I am actually trying to
achieve and whether there is a simpler, more streamlined approach.

With hindsight, if I can hold the macro in a separate file and copy it in to
the generated sheet then I will achieve my objective and simplify the master
sheet (where the initial macro is not strictly necessary). However when I
copy the exported macro into the generated sheet (from the *.cls file, using
ActiveWorkbook.VBProject.VBComponents.Import) it stores it as a separate
'class' object and it is not run when the workbook opens. Is there a simple
way round this or am I barking up the wrong tree?

Thanks again

"Allllen" wrote:

The workbook_open macro does not get copied because you are only copying the
sheets, not workbooks. The buttons work because they belong in the sheets.

To get around this, instead of copying the sheets that you need, you could
try copying the whole book, then removing the sheets that you DON'T need.
That's the easy way.

The hard way (see under creating an Event procedure)
http://www.cpearson.com/excel/vbe.htm

--
Allllen


"Phil N Dank" wrote:

I have a spreadsheet which I am using as a master document from which I want
to generate many copies of a single worksheet (I only want that particular
worksheet to appear in the copies, not all three worksheets that exist in the
master). The master spreadsheet contains a workbook_open macro which I would
like to include in all the copies.

I am using the sheets(sheetname).copy function to create a clone of the
master worksheet but the workbook_open macro is not getting copied across.
The worksheet also has a number of buttons and all these macros are going
across just fine.

Is it possible to copy the workbook_open macro across in this way? If not
how can I programmatically create a workbook_open macro in the new workbooks?

Thanks in advance

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
Making Macros Available in All Workbooks QUESTION-MARK Excel Worksheet Functions 2 May 23rd 06 01:47 PM
Hide Macro's in Toolbar / Macro's list sparx Excel Discussion (Misc queries) 2 May 6th 06 08:53 PM
how do I run excel 4.0 macros on excel 2000 RodolfoDallas Excel Discussion (Misc queries) 1 March 12th 06 03:14 AM
all macros failing - different workbooks different error messages. magpie Excel Discussion (Misc queries) 1 March 23rd 05 03:10 PM
Workbooks...I'll try this again... Markster Excel Discussion (Misc queries) 10 December 7th 04 10:12 PM


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