PC Review


Reply
Thread Tools Rate Thread

Chip Pearson's code to modify code

 
 
Otto Moehrbach
Guest
Posts: n/a
 
      9th Nov 2007
Excel XP & Win XP
I need to copy a module from one file to another. I went to Chip's site and
copied the code to do this. In that code,
"FromVBProject" is defined as "The VBProject that contains the module to be
copied." and
"ToVBProject" is the destination VBProject.
I took "VBProject" to be the name of the file, as in "Toolbar.xls".
Apparently that is not so because I am getting a "Type Mismatch" error.
Chip's code is a Function and my little macro simply calls that function, as
in:
Sub CopyTheModule()
MsgBox CopyModule("CreateToolbar", "Toolbar.xls", "RB Full
Database.xls", "False")
End Sub

Function CopyModule(ModuleName As String, _
FromVBProject As VBIDE.VBProject, _
ToVBProject As VBIDE.VBProject, _
OverwriteExisting As Boolean) As Boolean

The error is in "Toolbar.xls" in the sub and I imagine the error would move
on to the next file name as well.
Question: What am I doing wrong? Thanks for your time. Otto


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      9th Nov 2007
You need to pass the VBProjects to the function (or an object reference to
the vbprojects), not just the workbook or workbook names.

I've not worked extensively with the VBProject through code, but I think
something like this should work:

MsgBox CopyModule("CreateToolbar", Workbooks("Toolbar.xls").VBProject,
Workbooks("RB Full Database.xls").VBProject, "False")

and I believe you will need to set up a reference to the Microsoft Visual
Basic Extensibility Library (Tools/References).



"Otto Moehrbach" wrote:

> Excel XP & Win XP
> I need to copy a module from one file to another. I went to Chip's site and
> copied the code to do this. In that code,
> "FromVBProject" is defined as "The VBProject that contains the module to be
> copied." and
> "ToVBProject" is the destination VBProject.
> I took "VBProject" to be the name of the file, as in "Toolbar.xls".
> Apparently that is not so because I am getting a "Type Mismatch" error.
> Chip's code is a Function and my little macro simply calls that function, as
> in:
> Sub CopyTheModule()
> MsgBox CopyModule("CreateToolbar", "Toolbar.xls", "RB Full
> Database.xls", "False")
> End Sub
>
> Function CopyModule(ModuleName As String, _
> FromVBProject As VBIDE.VBProject, _
> ToVBProject As VBIDE.VBProject, _
> OverwriteExisting As Boolean) As Boolean
>
> The error is in "Toolbar.xls" in the sub and I imagine the error would move
> on to the next file name as well.
> Question: What am I doing wrong? Thanks for your time. Otto
>
>
>

 
Reply With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      9th Nov 2007
JMB
Thanks for responding. I'll try that in the morning. You're right about
the reference and I have already done that. Thanks again. Otto
"JMB" <(E-Mail Removed)> wrote in message
news:56E54EBA-4B92-4405-BCD3-(E-Mail Removed)...
> You need to pass the VBProjects to the function (or an object reference to
> the vbprojects), not just the workbook or workbook names.
>
> I've not worked extensively with the VBProject through code, but I think
> something like this should work:
>
> MsgBox CopyModule("CreateToolbar", Workbooks("Toolbar.xls").VBProject,
> Workbooks("RB Full Database.xls").VBProject, "False")
>
> and I believe you will need to set up a reference to the Microsoft Visual
> Basic Extensibility Library (Tools/References).
>
>
>
> "Otto Moehrbach" wrote:
>
>> Excel XP & Win XP
>> I need to copy a module from one file to another. I went to Chip's site
>> and
>> copied the code to do this. In that code,
>> "FromVBProject" is defined as "The VBProject that contains the module to
>> be
>> copied." and
>> "ToVBProject" is the destination VBProject.
>> I took "VBProject" to be the name of the file, as in "Toolbar.xls".
>> Apparently that is not so because I am getting a "Type Mismatch" error.
>> Chip's code is a Function and my little macro simply calls that function,
>> as
>> in:
>> Sub CopyTheModule()
>> MsgBox CopyModule("CreateToolbar", "Toolbar.xls", "RB Full
>> Database.xls", "False")
>> End Sub
>>
>> Function CopyModule(ModuleName As String, _
>> FromVBProject As VBIDE.VBProject, _
>> ToVBProject As VBIDE.VBProject, _
>> OverwriteExisting As Boolean) As Boolean
>>
>> The error is in "Toolbar.xls" in the sub and I imagine the error would
>> move
>> on to the next file name as well.
>> Question: What am I doing wrong? Thanks for your time. Otto
>>
>>
>>



 
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
Update Sheet code using VBA - question for Chip Pearson Basilisk96 Microsoft Excel Programming 3 3rd Dec 2007 01:02 AM
How to Use Chip Pearson's Text Import Code socrtwo@gmail.com Microsoft Excel Programming 12 23rd Aug 2006 02:28 PM
How Do I Modify Pearson's Code to Add "Treat Consecutive Delimiters As One"? Alicia7Jaynes@yahoo.com Microsoft Excel Programming 4 14th Jun 2006 12:23 AM
Problem with Pearson Code Ramthebuffs Microsoft Excel Programming 3 19th Jun 2005 08:02 PM
Help with Chip Pearson's Code for Deleting Blank Rows Rashid Khan Microsoft Excel Programming 6 30th Jun 2004 08:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:59 PM.