Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #108736 > unrolled thread

Is it possible to copy vba macros into a workbook using a vba macro to do the copying

Started byDesmond Walsh <deasmhuinbreathnach@gmail.com>
First post2016-04-10 10:02 -0700
Last post2016-04-11 10:23 +0100
Articles 7 — 3 participants

Back to article view | Back to microsoft.public.excel.programming


Contents

  Is it possible to copy vba macros into a workbook using a vba macro to do the copying Desmond Walsh <deasmhuinbreathnach@gmail.com> - 2016-04-10 10:02 -0700
    Re: Is it possible to copy vba macros into a workbook using a vba macro to do the copying GS <gs@v.invalid> - 2016-04-10 14:37 -0400
    Re: Is it possible to copy vba macros into a workbook using a vba macro to do the copying Desmond Walsh <deasmhuinbreathnach@gmail.com> - 2016-04-10 15:42 -0700
      Re: Is it possible to copy vba macros into a workbook using a vba macro to do the copying GS <gs@v.invalid> - 2016-04-11 09:38 -0400
        Re: Is it possible to copy vba macros into a workbook using a vba macro to do the copying Desmond Walsh <deasmhuinbreathnach@gmail.com> - 2016-04-11 13:01 -0700
          Re: Is it possible to copy vba macros into a workbook using a vba macro to do the copying GS <gs@v.invalid> - 2016-04-11 18:26 -0400
    Re: Is it possible to copy vba macros into a workbook using a vba macroto do the copying profilmuoitam18 <profilmuoitam18@gmail.com> - 2016-04-11 10:23 +0100

#108736 — Is it possible to copy vba macros into a workbook using a vba macro to do the copying

FromDesmond Walsh <deasmhuinbreathnach@gmail.com>
Date2016-04-10 10:02 -0700
SubjectIs it possible to copy vba macros into a workbook using a vba macro to do the copying
Message-ID<9975dded-e054-4512-b2ce-50560442704a@googlegroups.com>
I have a series of workbooks one for each year  handling budgetary data that prepares  tax information for the year in question.  If I modify a macro or add a new macro, I have to manually  make the modification in each of the workbooks (12 in all). Each workbook has links back to the preceding workbook so that cumulative data from year 1 can be presented in the current year.

I would like to make the VBA changes in the base year's workbook and then migrate that changed macro  to all the other 11 workbooks using VBA code. Is this possible ?.

I am already using PERSONAL.XLSM  to hold a library of commonly used macros. However, I think it is poor design to place macros common to one particular series of workbooks in PERSONAL.XLSM.

Looking forward to being enlightened. Thank you.

[toc] | [next] | [standalone]


#108737

FromGS <gs@v.invalid>
Date2016-04-10 14:37 -0400
Message-ID<nee6ae$o8i$1@dont-email.me>
In reply to#108736
You could put the macros in an XLAM (addin) that also loads a custom 
menu. This makes the current code always contained in a single 
(distributable) file, and obviates the need for your period files to 
contain any code at all. Just redistribute any new version of your 
addin as needed!

Normally, I'd 'tag' the project workbooks so the addin knows which 
files to make its menus available to. I use a template for the fiscal 
period file so a new one can be started in new fiscal periods.

So then...

  Addin:
    - contains all code/forms/features/functionality
    - creates/destroys its own custom menus at startup/shutdown
    - only enables menus when one of its project files is active

  Template:
    - reusable project file used by the addin for dedicated tasks
    - new template created by the addin for each new fiscal period

-- 
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
  comp.lang.basic.visual.misc
  microsoft.public.vb.general.discussion

[toc] | [prev] | [next] | [standalone]


#108738

FromDesmond Walsh <deasmhuinbreathnach@gmail.com>
Date2016-04-10 15:42 -0700
Message-ID<16e14a4c-0305-4296-a091-0a37572876fa@googlegroups.com>
In reply to#108736
On Sunday, April 10, 2016 at 1:02:14 PM UTC-4, Desmond Walsh wrote:
> I have a series of workbooks one for each year  handling budgetary data that prepares  tax information for the year in question.  If I modify a macro or add a new macro, I have to manually  make the modification in each of the workbooks (12 in all). Each workbook has links back to the preceding workbook so that cumulative data from year 1 can be presented in the current year.
> 
> I would like to make the VBA changes in the base year's workbook and then migrate that changed macro  to all the other 11 workbooks using VBA code. Is this possible ?.
> 
> I am already using PERSONAL.XLSM  to hold a library of commonly used macros. However, I think it is poor design to place macros common to one particular series of workbooks in PERSONAL.XLSM.
> 
> Looking forward to being enlightened. Thank you.

Actually, I found a VBA macro CopyModule on Chip Pearson's webite www.cpearson.com that does exactly what I want. The following test code shows how to use this macro.  

Sub test_CopyModule()
'
'    A test procedure to test the Vba macro CopyModule
'    NOTE 1: CopyModule is from Chip Pearson's site www.cpearson.com
'            (check topic VBA EDitor, Automating The VBA EDitor and its objects)
'    NOTE 2: The module may be any VBComponent such as ThisWorkbook, ModuleN,
'            SheetN or any form in Forms
'    Updated:    10-Apr-2016
'---------------------------------------------------------------------------
    Dim result              As Boolean
    Dim FromVBProject       As VBIDE.VBProject
    Dim ToVBProject         As VBIDE.VBProject
    Dim from_wb             As Workbook
    Dim to_wb               As Workbook
  
    Set from_wb = Workbooks("Tax_Section216_2005.xlsm")
    Set to_wb = Workbooks("test_copy_macro.xlsm")
    
    Set FromVBProject = from_wb.VBProject
    Set ToVBProject = to_wb.VBProject
   
    result = CopyModule("Module1", FromVBProject, ToVBProject, True)
End Sub

[toc] | [prev] | [next] | [standalone]


#108740

FromGS <gs@v.invalid>
Date2016-04-11 09:38 -0400
Message-ID<neg96k$bcq$1@dont-email.me>
In reply to#108738
This will copy the entire module, resulting in duplicate procedure 
names if you don't remove the existing module first. Not to mention 
having to do maintenance on every workbook, wouldn't it be easier (and 
more productive/efficient) to maintain 1 addin?

-- 
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
  comp.lang.basic.visual.misc
  microsoft.public.vb.general.discussion

[toc] | [prev] | [next] | [standalone]


#108742

FromDesmond Walsh <deasmhuinbreathnach@gmail.com>
Date2016-04-11 13:01 -0700
Message-ID<59ab2142-27c9-44f3-8d6e-6a22dc07581c@googlegroups.com>
In reply to#108740
On Monday, April 11, 2016 at 9:38:40 AM UTC-4, GS wrote:
> This will copy the entire module, resulting in duplicate procedure 
> names if you don't remove the existing module first. Not to mention 
> having to do maintenance on every workbook, wouldn't it be easier (and 
> more productive/efficient) to maintain 1 addin?
> 
> -- 
> Garry
> 
> Free usenet access at http://www.eternal-september.org
> Classic VB Users Regroup!
>   comp.lang.basic.visual.misc
>   microsoft.public.vb.general.discussion

Yes, your point is very valid. I will look into the addin technique that you suggested and report if I have any difficulty. Thank you for taking the time to reply

Desmond 

[toc] | [prev] | [next] | [standalone]


#108743

FromGS <gs@v.invalid>
Date2016-04-11 18:26 -0400
Message-ID<neh84m$d1f$1@dont-email.me>
In reply to#108742
> On Monday, April 11, 2016 at 9:38:40 AM UTC-4, GS wrote:
>> This will copy the entire module, resulting in duplicate procedure 
>> names if you don't remove the existing module first. Not to mention 
>> having to do maintenance on every workbook, wouldn't it be easier 
>> (and  more productive/efficient) to maintain 1 addin?
>> 
>> -- 
>> Garry
>> 
>> Free usenet access at http://www.eternal-september.org
>> Classic VB Users Regroup!
>>   comp.lang.basic.visual.misc
>>   microsoft.public.vb.general.discussion
>
> Yes, your point is very valid. I will look into the addin technique 
> that you suggested and report if I have any difficulty. Thank you for 
> taking the time to reply
>
> Desmond 

If you do a lot of this sort of work, addins would be of great benefit. 
For reference material you could check out the following books...

  http://www.appspro.com/Books/Books.htm

-- 
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
  comp.lang.basic.visual.misc
  microsoft.public.vb.general.discussion

[toc] | [prev] | [next] | [standalone]


#108739 — Re: Is it possible to copy vba macros into a workbook using a vba macroto do the copying

Fromprofilmuoitam18 <profilmuoitam18@gmail.com>
Date2016-04-11 10:23 +0100
SubjectRe: Is it possible to copy vba macros into a workbook using a vba macroto do the copying
Message-ID<profilmuoitam18.11512888@excelbanter.com>
In reply to#108736
M&#7901;i b&#7841;n &#273;&#7885;c bài vi&#7871;t v&#7873; b&#7845;t
&#273;&#7897;ng s&#7843;n

'Choáng ng&#7907;p nh&#7919;ng phòng khách s&#7841;n &#273;&#7855;t
&#273;&#7887; nh&#7845;t th&#7871; gi&#7899;i '
(http://tinyurl.com/zba7vpn)
'C&#417; ng&#417;i sang tr&#7885;ng c&#7911;a bà ch&#7911; công ty
ng&#432;&#7901;i m&#7851;u Venus ' (http://tinyurl.com/jgy5rdc)
'Soi ngôi nhà ng&#7889;n núi ti&#7873;n c&#7911;a ca s&#297; Trang Nhung
' (http://tinyurl.com/z3k8hj8)




-- 
profilmuoitam18

[toc] | [prev] | [standalone]


Back to top | Article view | microsoft.public.excel.programming


csiph-web