PC Review


Reply
Thread Tools Rate Thread

Copying code behind from a sheet to a sheet in another workbook.

 
 
=?Utf-8?B?TmF5YW4=?=
Guest
Posts: n/a
 
      22nd Jun 2007
Hello,

(Environment Excel 2003)

I have a parent workbook (Say WB1.XLS) which contains code behind in its
sheet1.
I made a copy of WB1 say WB2.XLS.

Now the code behind in sheet1 in WB1 changed.

I need a programm that can compare the code between WB1.sheet1 and WB2.sheet1.

if vba code is different then
copy the code from WB1.Sheet1 to WB2.sheet1

At run time I can export/Import the modules (.BAS, .FRM, .CLS) . I tried
exporting sheets but they are stored as .CLS extentions and when I import
these sheets they come back as class modules (.CLS) 'not useful'.

With code I can get the count of lines of code for each sheet (which I can
use to compare ) but how to get the code itself from the sheet and once i get
the code how to insert that code in another sheet to overwrite ?

Any suggestions or ideas.

Thanks in advance

Nayan
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk5X?=
Guest
Posts: n/a
 
      22nd Jun 2007
If you know that the code in WB1 changed and you want to change the code in
WB2 only if WB1 changed, then you don't need to check the code of WB2. I
presume you might have multiple workbooks you are looking to change. You
could set up code that will loop through each individual workbook and make
the change.

Let me know if I'm thinking about this the wrong way.


--
JNW


"Nayan" wrote:

> Hello,
>
> (Environment Excel 2003)
>
> I have a parent workbook (Say WB1.XLS) which contains code behind in its
> sheet1.
> I made a copy of WB1 say WB2.XLS.
>
> Now the code behind in sheet1 in WB1 changed.
>
> I need a programm that can compare the code between WB1.sheet1 and WB2.sheet1.
>
> if vba code is different then
> copy the code from WB1.Sheet1 to WB2.sheet1
>
> At run time I can export/Import the modules (.BAS, .FRM, .CLS) . I tried
> exporting sheets but they are stored as .CLS extentions and when I import
> these sheets they come back as class modules (.CLS) 'not useful'.
>
> With code I can get the count of lines of code for each sheet (which I can
> use to compare ) but how to get the code itself from the sheet and once i get
> the code how to insert that code in another sheet to overwrite ?
>
> Any suggestions or ideas.
>
> Thanks in advance
>
> Nayan

 
Reply With Quote
 
=?Utf-8?B?TmF5YW4=?=
Guest
Posts: n/a
 
      25th Jun 2007
JNW,
Thanks for the reply.
Yes I have multiple copies of a parent WB.

I do not have any information before hand if the code between WB1.sheet1 and
WB2.sheet1 is diff or same. So I need to check if its same or not before
replicating code fron one sheet to another one.

They come to me from an external source. I just need to sink the code
between these sheets

Please let me know if more information is needed.

Thanks for your time

Nayan

"JNW" wrote:

> If you know that the code in WB1 changed and you want to change the code in
> WB2 only if WB1 changed, then you don't need to check the code of WB2. I
> presume you might have multiple workbooks you are looking to change. You
> could set up code that will loop through each individual workbook and make
> the change.
>
> Let me know if I'm thinking about this the wrong way.
>
>
> --
> JNW
>
>
> "Nayan" wrote:
>
> > Hello,
> >
> > (Environment Excel 2003)
> >
> > I have a parent workbook (Say WB1.XLS) which contains code behind in its
> > sheet1.
> > I made a copy of WB1 say WB2.XLS.
> >
> > Now the code behind in sheet1 in WB1 changed.
> >
> > I need a programm that can compare the code between WB1.sheet1 and WB2.sheet1.
> >
> > if vba code is different then
> > copy the code from WB1.Sheet1 to WB2.sheet1
> >
> > At run time I can export/Import the modules (.BAS, .FRM, .CLS) . I tried
> > exporting sheets but they are stored as .CLS extentions and when I import
> > these sheets they come back as class modules (.CLS) 'not useful'.
> >
> > With code I can get the count of lines of code for each sheet (which I can
> > use to compare ) but how to get the code itself from the sheet and once i get
> > the code how to insert that code in another sheet to overwrite ?
> >
> > Any suggestions or ideas.
> >
> > Thanks in advance
> >
> > Nayan

 
Reply With Quote
 
=?Utf-8?B?Sk5X?=
Guest
Posts: n/a
 
      25th Jun 2007
To my knowledge there is no way to compare code from two workbooks line by
line, or even command by command.

With what I understand, it seems that there are two options.

1) replace the code in the the workbooks on a scheduled basis. i.e. every
Friday run code that will change the workbooks.

2) have the third party create the code as an add-in. This way, only the
add-in you receive changes and the workbooks don't have to.

--
JNW


"Nayan" wrote:

> JNW,
> Thanks for the reply.
> Yes I have multiple copies of a parent WB.
>
> I do not have any information before hand if the code between WB1.sheet1 and
> WB2.sheet1 is diff or same. So I need to check if its same or not before
> replicating code fron one sheet to another one.
>
> They come to me from an external source. I just need to sink the code
> between these sheets
>
> Please let me know if more information is needed.
>
> Thanks for your time
>
> Nayan
>
> "JNW" wrote:
>
> > If you know that the code in WB1 changed and you want to change the code in
> > WB2 only if WB1 changed, then you don't need to check the code of WB2. I
> > presume you might have multiple workbooks you are looking to change. You
> > could set up code that will loop through each individual workbook and make
> > the change.
> >
> > Let me know if I'm thinking about this the wrong way.
> >
> >
> > --
> > JNW
> >
> >
> > "Nayan" wrote:
> >
> > > Hello,
> > >
> > > (Environment Excel 2003)
> > >
> > > I have a parent workbook (Say WB1.XLS) which contains code behind in its
> > > sheet1.
> > > I made a copy of WB1 say WB2.XLS.
> > >
> > > Now the code behind in sheet1 in WB1 changed.
> > >
> > > I need a programm that can compare the code between WB1.sheet1 and WB2.sheet1.
> > >
> > > if vba code is different then
> > > copy the code from WB1.Sheet1 to WB2.sheet1
> > >
> > > At run time I can export/Import the modules (.BAS, .FRM, .CLS) . I tried
> > > exporting sheets but they are stored as .CLS extentions and when I import
> > > these sheets they come back as class modules (.CLS) 'not useful'.
> > >
> > > With code I can get the count of lines of code for each sheet (which I can
> > > use to compare ) but how to get the code itself from the sheet and once i get
> > > the code how to insert that code in another sheet to overwrite ?
> > >
> > > Any suggestions or ideas.
> > >
> > > Thanks in advance
> > >
> > > Nayan

 
Reply With Quote
 
=?Utf-8?B?TmF5YW4=?=
Guest
Posts: n/a
 
      25th Jun 2007
Hello JNW,

If I have to follow point 1 as mentioned below, How do I programmatically
copy code from one worksheet to another one?

(1. replace the code in the the workbooks on a scheduled basis. i.e. every
Friday run code that will change the workbooks.)

Thanks

Nayan
"JNW" wrote:

> To my knowledge there is no way to compare code from two workbooks line by
> line, or even command by command.
>
> With what I understand, it seems that there are two options.
>
> 1) replace the code in the the workbooks on a scheduled basis. i.e. every
> Friday run code that will change the workbooks.
>
> 2) have the third party create the code as an add-in. This way, only the
> add-in you receive changes and the workbooks don't have to.
>
> --
> JNW
>
>
> "Nayan" wrote:
>
> > JNW,
> > Thanks for the reply.
> > Yes I have multiple copies of a parent WB.
> >
> > I do not have any information before hand if the code between WB1.sheet1 and
> > WB2.sheet1 is diff or same. So I need to check if its same or not before
> > replicating code fron one sheet to another one.
> >
> > They come to me from an external source. I just need to sink the code
> > between these sheets
> >
> > Please let me know if more information is needed.
> >
> > Thanks for your time
> >
> > Nayan
> >
> > "JNW" wrote:
> >
> > > If you know that the code in WB1 changed and you want to change the code in
> > > WB2 only if WB1 changed, then you don't need to check the code of WB2. I
> > > presume you might have multiple workbooks you are looking to change. You
> > > could set up code that will loop through each individual workbook and make
> > > the change.
> > >
> > > Let me know if I'm thinking about this the wrong way.
> > >
> > >
> > > --
> > > JNW
> > >
> > >
> > > "Nayan" wrote:
> > >
> > > > Hello,
> > > >
> > > > (Environment Excel 2003)
> > > >
> > > > I have a parent workbook (Say WB1.XLS) which contains code behind in its
> > > > sheet1.
> > > > I made a copy of WB1 say WB2.XLS.
> > > >
> > > > Now the code behind in sheet1 in WB1 changed.
> > > >
> > > > I need a programm that can compare the code between WB1.sheet1 and WB2.sheet1.
> > > >
> > > > if vba code is different then
> > > > copy the code from WB1.Sheet1 to WB2.sheet1
> > > >
> > > > At run time I can export/Import the modules (.BAS, .FRM, .CLS) . I tried
> > > > exporting sheets but they are stored as .CLS extentions and when I import
> > > > these sheets they come back as class modules (.CLS) 'not useful'.
> > > >
> > > > With code I can get the count of lines of code for each sheet (which I can
> > > > use to compare ) but how to get the code itself from the sheet and once i get
> > > > the code how to insert that code in another sheet to overwrite ?
> > > >
> > > > Any suggestions or ideas.
> > > >
> > > > Thanks in advance
> > > >
> > > > Nayan

 
Reply With Quote
 
=?Utf-8?B?Sk5X?=
Guest
Posts: n/a
 
      25th Jun 2007
Chip Pearson explains it way better than I ever could!

Check out this site. It's got everything you need to know to get you
started editing the VBE.
(a
herf:http://www.cpearson.com/excel/vbe.htm>http://www.cpearson.com/excel/vbe.htm</a>



--
JNW


"Nayan" wrote:

> Hello JNW,
>
> If I have to follow point 1 as mentioned below, How do I programmatically
> copy code from one worksheet to another one?
>
> (1. replace the code in the the workbooks on a scheduled basis. i.e. every
> Friday run code that will change the workbooks.)
>
> Thanks
>
> Nayan
> "JNW" wrote:
>
> > To my knowledge there is no way to compare code from two workbooks line by
> > line, or even command by command.
> >
> > With what I understand, it seems that there are two options.
> >
> > 1) replace the code in the the workbooks on a scheduled basis. i.e. every
> > Friday run code that will change the workbooks.
> >
> > 2) have the third party create the code as an add-in. This way, only the
> > add-in you receive changes and the workbooks don't have to.
> >
> > --
> > JNW
> >
> >
> > "Nayan" wrote:
> >
> > > JNW,
> > > Thanks for the reply.
> > > Yes I have multiple copies of a parent WB.
> > >
> > > I do not have any information before hand if the code between WB1.sheet1 and
> > > WB2.sheet1 is diff or same. So I need to check if its same or not before
> > > replicating code fron one sheet to another one.
> > >
> > > They come to me from an external source. I just need to sink the code
> > > between these sheets
> > >
> > > Please let me know if more information is needed.
> > >
> > > Thanks for your time
> > >
> > > Nayan
> > >
> > > "JNW" wrote:
> > >
> > > > If you know that the code in WB1 changed and you want to change the code in
> > > > WB2 only if WB1 changed, then you don't need to check the code of WB2. I
> > > > presume you might have multiple workbooks you are looking to change. You
> > > > could set up code that will loop through each individual workbook and make
> > > > the change.
> > > >
> > > > Let me know if I'm thinking about this the wrong way.
> > > >
> > > >
> > > > --
> > > > JNW
> > > >
> > > >
> > > > "Nayan" wrote:
> > > >
> > > > > Hello,
> > > > >
> > > > > (Environment Excel 2003)
> > > > >
> > > > > I have a parent workbook (Say WB1.XLS) which contains code behind in its
> > > > > sheet1.
> > > > > I made a copy of WB1 say WB2.XLS.
> > > > >
> > > > > Now the code behind in sheet1 in WB1 changed.
> > > > >
> > > > > I need a programm that can compare the code between WB1.sheet1 and WB2.sheet1.
> > > > >
> > > > > if vba code is different then
> > > > > copy the code from WB1.Sheet1 to WB2.sheet1
> > > > >
> > > > > At run time I can export/Import the modules (.BAS, .FRM, .CLS) . I tried
> > > > > exporting sheets but they are stored as .CLS extentions and when I import
> > > > > these sheets they come back as class modules (.CLS) 'not useful'.
> > > > >
> > > > > With code I can get the count of lines of code for each sheet (which I can
> > > > > use to compare ) but how to get the code itself from the sheet and once i get
> > > > > the code how to insert that code in another sheet to overwrite ?
> > > > >
> > > > > Any suggestions or ideas.
> > > > >
> > > > > Thanks in advance
> > > > >
> > > > > Nayan

 
Reply With Quote
 
=?Utf-8?B?TmF5YW4=?=
Guest
Posts: n/a
 
      29th Jun 2007
Thanks for reply.

I have figured this out.

FYI- I am exporting the code in a text file and importing using VBproject
object model

Thanks again

Nayan



"JNW" wrote:

> Chip Pearson explains it way better than I ever could!
>
> Check out this site. It's got everything you need to know to get you
> started editing the VBE.
> (a
> herf:http://www.cpearson.com/excel/vbe.htm>http://www.cpearson.com/excel/vbe.htm</a>
>
>
>
> --
> JNW
>
>
> "Nayan" wrote:
>
> > Hello JNW,
> >
> > If I have to follow point 1 as mentioned below, How do I programmatically
> > copy code from one worksheet to another one?
> >
> > (1. replace the code in the the workbooks on a scheduled basis. i.e. every
> > Friday run code that will change the workbooks.)
> >
> > Thanks
> >
> > Nayan
> > "JNW" wrote:
> >
> > > To my knowledge there is no way to compare code from two workbooks line by
> > > line, or even command by command.
> > >
> > > With what I understand, it seems that there are two options.
> > >
> > > 1) replace the code in the the workbooks on a scheduled basis. i.e. every
> > > Friday run code that will change the workbooks.
> > >
> > > 2) have the third party create the code as an add-in. This way, only the
> > > add-in you receive changes and the workbooks don't have to.
> > >
> > > --
> > > JNW
> > >
> > >
> > > "Nayan" wrote:
> > >
> > > > JNW,
> > > > Thanks for the reply.
> > > > Yes I have multiple copies of a parent WB.
> > > >
> > > > I do not have any information before hand if the code between WB1.sheet1 and
> > > > WB2.sheet1 is diff or same. So I need to check if its same or not before
> > > > replicating code fron one sheet to another one.
> > > >
> > > > They come to me from an external source. I just need to sink the code
> > > > between these sheets
> > > >
> > > > Please let me know if more information is needed.
> > > >
> > > > Thanks for your time
> > > >
> > > > Nayan
> > > >
> > > > "JNW" wrote:
> > > >
> > > > > If you know that the code in WB1 changed and you want to change the code in
> > > > > WB2 only if WB1 changed, then you don't need to check the code of WB2. I
> > > > > presume you might have multiple workbooks you are looking to change. You
> > > > > could set up code that will loop through each individual workbook and make
> > > > > the change.
> > > > >
> > > > > Let me know if I'm thinking about this the wrong way.
> > > > >
> > > > >
> > > > > --
> > > > > JNW
> > > > >
> > > > >
> > > > > "Nayan" wrote:
> > > > >
> > > > > > Hello,
> > > > > >
> > > > > > (Environment Excel 2003)
> > > > > >
> > > > > > I have a parent workbook (Say WB1.XLS) which contains code behind in its
> > > > > > sheet1.
> > > > > > I made a copy of WB1 say WB2.XLS.
> > > > > >
> > > > > > Now the code behind in sheet1 in WB1 changed.
> > > > > >
> > > > > > I need a programm that can compare the code between WB1.sheet1 and WB2.sheet1.
> > > > > >
> > > > > > if vba code is different then
> > > > > > copy the code from WB1.Sheet1 to WB2.sheet1
> > > > > >
> > > > > > At run time I can export/Import the modules (.BAS, .FRM, .CLS) . I tried
> > > > > > exporting sheets but they are stored as .CLS extentions and when I import
> > > > > > these sheets they come back as class modules (.CLS) 'not useful'.
> > > > > >
> > > > > > With code I can get the count of lines of code for each sheet (which I can
> > > > > > use to compare ) but how to get the code itself from the sheet and once i get
> > > > > > the code how to insert that code in another sheet to overwrite ?
> > > > > >
> > > > > > Any suggestions or ideas.
> > > > > >
> > > > > > Thanks in advance
> > > > > >
> > > > > > Nayan

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save each sheet of multi-sheet workbook as a single-sheet workbook CTB Microsoft Excel Programming 3 17th May 2011 08:40 AM
Remove VB code when copying sheet to new workbook Tucker Microsoft Excel Programming 2 15th Apr 2009 07:29 AM
Copying a protected sheet to another sheet or workbook loses prote Rudy Microsoft Excel Crashes 0 30th Nov 2007 10:17 PM
Copying sheet containing GetPivotData, new sheet references old workbook! rivkarak Microsoft Excel Programming 0 18th Jan 2007 11:31 AM
Copying data from workbook/sheets to another workbook/sheet =?Utf-8?B?eXVrb25fcGhpbA==?= Microsoft Excel Programming 0 26th Jul 2006 07:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:47 AM.