Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Help with CopyModule coding

Hello all!

I need to update the VBA code in a tool used by numerous people across the US and found Chip Pearson's code that would seem to solve my problem; the code is he
http://www.cpearson.com/excel/vbe.aspx

However, when I try to use it I get the following Compile Error:
Function call on left-hand side of assignment must return Variant or Object

My code looks like this:

Sub patch()

Dim VBAEditor As VBIDE.VBE
Dim ThisVBProj As VBIDE.VBProject
Dim ThatVBProj As VBIDE.VBProject

Set VBAEditor = Application.VBE
Set ThisVBProj = VBAEditor.ActiveVBProject
Set ThatVBProj = Application.Workbook("Patch Test.xlsm").VBProject

CopyModule("CODE_Clear_Tertial_Data", ThisVBProj, ThatVBProj, False) = True

End Sub

Any/all help is greatly appreciated!

Thanks,
Ray
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Help with CopyModule coding

Ray wrote:
CopyModule("CODE_Clear_Tertial_Data", ThisVBProj, ThatVBProj, False)= True



CopyModule "CODE_Clear_Tertial_Data", ThisVBProj, ThatVBProj, False


eventually

if CopyModule("CODE_Clear_Tertial_Data", ThisVBProj, ThatVBProj, False)=
True then

end if


  #3   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Help with CopyModule coding

witek,

I appreciate the reply, but the CopyModule coding seems to be right:
-- the 'false' at the end is an "over-write existing module' setting
-- the 'true' at the end of the line (=true) is the way it needs to be called according to Chip's site

If I remove the "= True" part, I get an error of "Expected ="

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Help with CopyModule coding

Ray wrote:
witek,

I appreciate the reply, but the CopyModule coding seems to be right:
-- the 'false' at the end is an "over-write existing module' setting
-- the 'true' at the end of the line (=true) is the way it needs to be called according to Chip's site

If I remove the "= True" part, I get an error of "Expected ="



remove ( )


  #5   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Help with CopyModule coding

Ok, removed the () ... and now it compiles, BUT throws a new error ...

" Object doesn't support this property or method" on the "Set ThatVBProj" line.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Help with CopyModule coding

witek,

I appreciate the reply, but the CopyModule coding seems to be right:
-- the 'false' at the end is an "over-write existing module' setting
-- the 'true' at the end of the line (=true) is the way it needs to
be called according to Chip's site

If I remove the "= True" part, I get an error of "Expected ="


Chip's example of using CopyModule works exactly as Witek suggests.
CopyModule is a function that returns a Boolean (True/False) based on
its success/failure. Your code should handle that return something
like...

If CopyModule Then 'success
'do this
Else 'failure
'do that
End if

--
Garry

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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Help with CopyModule coding

hi Ray,

do you added a reference to the VBA Extensibility library ?

isabelle

Le 2015-08-28 11:23, Ray a écrit :
Ok, removed the () ... and now it compiles, BUT throws a new error ...

" Object doesn't support this property or method" on the "Set ThatVBProj" line.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Help with CopyModule coding

hi Ray,

do you added a reference to the VBA Extensibility library ?

isabelle

Le 2015-08-28 11:23, Ray a écrit :
Ok, removed the () ... and now it compiles, BUT throws a new error
...

" Object doesn't support this property or method" on the "Set
ThatVBProj" line.


Good question! I ass-u-me'd he read Chip's article and thus *followed
the instructions within*!

--
Garry

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


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Help with CopyModule coding


Le 2015-08-28 18:03, GS a écrit :
Good question! I ass-u-me'd he read Chip's article and thus *followed the
instructions within*!


hi Garry,

sometimes, i do zigzag reading, so...

isabelle
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
Any luck using CopyModule? Janie Excel Programming 11 October 9th 08 02:56 PM
How to fix the coding? Eric Excel Worksheet Functions 0 February 26th 08 03:38 AM
How to fix the coding? Eric Excel Worksheet Functions 4 June 20th 07 02:42 PM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM


All times are GMT +1. The time now is 01:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"