PC Review


Reply
Thread Tools Rate Thread

Call an ADDIN function from VBA code

 
 
=?Utf-8?B?TWFydmlu?=
Guest
Posts: n/a
 
      22nd Jun 2007
I have a function in an addin that is loaded. I seem unable to come up with
the syntax in VBA code to get it to function properly.

As a workbook function it is used as
=topleft(r)
where r is a range

If I copy the code into the module, it is used as

rtl=topleft(r)

How do I use it without cloning the code into the module?

Thanks.
 
Reply With Quote
 
 
 
 
papou
Guest
Posts: n/a
 
      22nd Jun 2007
Hi Marvin
Use Application.run "YourAddin.xla",Argument

HTH
Cordially
Pascal

"Marvin" <(E-Mail Removed)> a écrit dans le message de news:
05F1B491-B825-4172-A943-(E-Mail Removed)...
>I have a function in an addin that is loaded. I seem unable to come up
>with
> the syntax in VBA code to get it to function properly.
>
> As a workbook function it is used as
> =topleft(r)
> where r is a range
>
> If I copy the code into the module, it is used as
>
> rtl=topleft(r)
>
> How do I use it without cloning the code into the module?
>
> Thanks.



 
Reply With Quote
 
=?Utf-8?B?TWFydmlu?=
Guest
Posts: n/a
 
      22nd Jun 2007
This syntax allows execution, but does not allow for a return value from the
function in ther ADDIN.

"papou" wrote:

> Hi Marvin
> Use Application.run "YourAddin.xla",Argument
>
> HTH
> Cordially
> Pascal
>
> "Marvin" <(E-Mail Removed)> a écrit dans le message de news:
> 05F1B491-B825-4172-A943-(E-Mail Removed)...
> >I have a function in an addin that is loaded. I seem unable to come up
> >with
> > the syntax in VBA code to get it to function properly.
> >
> > As a workbook function it is used as
> > =topleft(r)
> > where r is a range
> >
> > If I copy the code into the module, it is used as
> >
> > rtl=topleft(r)
> >
> > How do I use it without cloning the code into the module?
> >
> > Thanks.

>
>
>

 
Reply With Quote
 
papou
Guest
Posts: n/a
 
      25th Jun 2007
Hi Marvin
Yes you can return the value with :
MyValue = Application.run "YourAddin.xla",Argument

HTH
Cordially
Pascal

"Marvin" <(E-Mail Removed)> a écrit dans le message de news:
54F31A74-838A-4F37-BC8C-(E-Mail Removed)...
> This syntax allows execution, but does not allow for a return value from
> the
> function in ther ADDIN.
>
> "papou" wrote:
>
>> Hi Marvin
>> Use Application.run "YourAddin.xla",Argument
>>
>> HTH
>> Cordially
>> Pascal
>>
>> "Marvin" <(E-Mail Removed)> a écrit dans le message de
>> news:
>> 05F1B491-B825-4172-A943-(E-Mail Removed)...
>> >I have a function in an addin that is loaded. I seem unable to come up
>> >with
>> > the syntax in VBA code to get it to function properly.
>> >
>> > As a workbook function it is used as
>> > =topleft(r)
>> > where r is a range
>> >
>> > If I copy the code into the module, it is used as
>> >
>> > rtl=topleft(r)
>> >
>> > How do I use it without cloning the code into the module?
>> >
>> > Thanks.

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?TWFydmlu?=
Guest
Posts: n/a
 
      25th Jun 2007
Unfortunately, the syntax you suggest doesn't work. My code is:

rtl=application.run "Marvin's Private Functions.xla!topleft",r

It produces a compiler error indicating

Expected: end of statement

"papou" wrote:

> Hi Marvin
> Yes you can return the value with :
> MyValue = Application.run "YourAddin.xla",Argument
>
> HTH
> Cordially
> Pascal
>
> "Marvin" <(E-Mail Removed)> a écrit dans le message de news:
> 54F31A74-838A-4F37-BC8C-(E-Mail Removed)...
> > This syntax allows execution, but does not allow for a return value from
> > the
> > function in ther ADDIN.
> >
> > "papou" wrote:
> >
> >> Hi Marvin
> >> Use Application.run "YourAddin.xla",Argument
> >>
> >> HTH
> >> Cordially
> >> Pascal
> >>
> >> "Marvin" <(E-Mail Removed)> a écrit dans le message de
> >> news:
> >> 05F1B491-B825-4172-A943-(E-Mail Removed)...
> >> >I have a function in an addin that is loaded. I seem unable to come up
> >> >with
> >> > the syntax in VBA code to get it to function properly.
> >> >
> >> > As a workbook function it is used as
> >> > =topleft(r)
> >> > where r is a range
> >> >
> >> > If I copy the code into the module, it is used as
> >> >
> >> > rtl=topleft(r)
> >> >
> >> > How do I use it without cloning the code into the module?
> >> >
> >> > Thanks.
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Jun 2007
maybe
rtl=application.run("'Marvin's Private Functions.xla'!topleft", r)

Notice the ()'s and the apostrophes.


Marvin wrote:
>
> Unfortunately, the syntax you suggest doesn't work. My code is:
>
> rtl=application.run "Marvin's Private Functions.xla!topleft",r
>
> It produces a compiler error indicating
>
> Expected: end of statement
>
> "papou" wrote:
>
> > Hi Marvin
> > Yes you can return the value with :
> > MyValue = Application.run "YourAddin.xla",Argument
> >
> > HTH
> > Cordially
> > Pascal
> >
> > "Marvin" <(E-Mail Removed)> a écrit dans le message de news:
> > 54F31A74-838A-4F37-BC8C-(E-Mail Removed)...
> > > This syntax allows execution, but does not allow for a return value from
> > > the
> > > function in ther ADDIN.
> > >
> > > "papou" wrote:
> > >
> > >> Hi Marvin
> > >> Use Application.run "YourAddin.xla",Argument
> > >>
> > >> HTH
> > >> Cordially
> > >> Pascal
> > >>
> > >> "Marvin" <(E-Mail Removed)> a écrit dans le message de
> > >> news:
> > >> 05F1B491-B825-4172-A943-(E-Mail Removed)...
> > >> >I have a function in an addin that is loaded. I seem unable to come up
> > >> >with
> > >> > the syntax in VBA code to get it to function properly.
> > >> >
> > >> > As a workbook function it is used as
> > >> > =topleft(r)
> > >> > where r is a range
> > >> >
> > >> > If I copy the code into the module, it is used as
> > >> >
> > >> > rtl=topleft(r)
> > >> >
> > >> > How do I use it without cloning the code into the module?
> > >> >
> > >> > Thanks.
> > >>
> > >>
> > >>

> >
> >
> >


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?TWFydmlu?=
Guest
Posts: n/a
 
      25th Jun 2007
Dave-

Thanks. Syntactically it is now correct, but the ADDIN is not found even if
I use the complete path in the file name.

"Dave Peterson" wrote:

> maybe
> rtl=application.run("'Marvin's Private Functions.xla'!topleft", r)
>
> Notice the ()'s and the apostrophes.
>
>
> Marvin wrote:
> >
> > Unfortunately, the syntax you suggest doesn't work. My code is:
> >
> > rtl=application.run "Marvin's Private Functions.xla!topleft",r
> >
> > It produces a compiler error indicating
> >
> > Expected: end of statement
> >
> > "papou" wrote:
> >
> > > Hi Marvin
> > > Yes you can return the value with :
> > > MyValue = Application.run "YourAddin.xla",Argument
> > >
> > > HTH
> > > Cordially
> > > Pascal
> > >
> > > "Marvin" <(E-Mail Removed)> a écrit dans le message de news:
> > > 54F31A74-838A-4F37-BC8C-(E-Mail Removed)...
> > > > This syntax allows execution, but does not allow for a return value from
> > > > the
> > > > function in ther ADDIN.
> > > >
> > > > "papou" wrote:
> > > >
> > > >> Hi Marvin
> > > >> Use Application.run "YourAddin.xla",Argument
> > > >>
> > > >> HTH
> > > >> Cordially
> > > >> Pascal
> > > >>
> > > >> "Marvin" <(E-Mail Removed)> a écrit dans le message de
> > > >> news:
> > > >> 05F1B491-B825-4172-A943-(E-Mail Removed)...
> > > >> >I have a function in an addin that is loaded. I seem unable to come up
> > > >> >with
> > > >> > the syntax in VBA code to get it to function properly.
> > > >> >
> > > >> > As a workbook function it is used as
> > > >> > =topleft(r)
> > > >> > where r is a range
> > > >> >
> > > >> > If I copy the code into the module, it is used as
> > > >> >
> > > >> > rtl=topleft(r)
> > > >> >
> > > >> > How do I use it without cloning the code into the module?
> > > >> >
> > > >> > Thanks.
> > > >>
> > > >>
> > > >>
> > >
> > >
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Randy Harmelink
Guest
Posts: n/a
 
      25th Jun 2007
In order to make the functions of the add-in available like normal VBA
functions, you need to use the menu option > Tools > References and
add a reference to the add-in project to the VBE project. Then, you
should be able to just do something like this in your VBA code:

x = topleft(Range(r))

On Jun 22, 6:46 am, Marvin <Mar...@discussions.microsoft.com> wrote:
> I have a function in an addin that is loaded. I seem unable to come up with
> the syntax in VBA code to get it to function properly.
>
> As a workbook function it is used as
> =topleft(r)
> where r is a range
>
> If I copy the code into the module, it is used as
>
> rtl=topleft(r)
>
> How do I use it without cloning the code into the module?
>
> Thanks.



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Jun 2007
Make sure that the addin is open.

If it is, then try this manually:

rtl=application.run("'Marvin''s Private Functions.xla'!topleft", r)
(notice the '' in Marvin''s.)

If it works there, then you need to do the same in your code.

If the addin may be closed:

dim testwkbk as workbook
dim MarvFilename as string
marvfilename = "marvin's private functions.xla"
set testwkbk = nothing
on error resume next
set testwkbk = workbooks(marvfilename)
on error goto 0

if testwkbk is nothing then
set testwkbk = workbooks.open("C:\somepath\" & marvfilename)
end if

'and either this:
rtl=application.run("'" & testwkbk.name & "'!topleft", r)
or
fix up that appostrophe:
rtl=application.run("'" & application.substitute(testwkbk.name, "'", "''") _
& "'!topleft", r)

xl2k added Replace instead of using application.substitute.

======
Untested...


Marvin wrote:
>
> Dave-
>
> Thanks. Syntactically it is now correct, but the ADDIN is not found even if
> I use the complete path in the file name.
>
> "Dave Peterson" wrote:
>
> > maybe
> > rtl=application.run("'Marvin's Private Functions.xla'!topleft", r)
> >
> > Notice the ()'s and the apostrophes.
> >
> >
> > Marvin wrote:
> > >
> > > Unfortunately, the syntax you suggest doesn't work. My code is:
> > >
> > > rtl=application.run "Marvin's Private Functions.xla!topleft",r
> > >
> > > It produces a compiler error indicating
> > >
> > > Expected: end of statement
> > >
> > > "papou" wrote:
> > >
> > > > Hi Marvin
> > > > Yes you can return the value with :
> > > > MyValue = Application.run "YourAddin.xla",Argument
> > > >
> > > > HTH
> > > > Cordially
> > > > Pascal
> > > >
> > > > "Marvin" <(E-Mail Removed)> a écrit dans le message de news:
> > > > 54F31A74-838A-4F37-BC8C-(E-Mail Removed)...
> > > > > This syntax allows execution, but does not allow for a return value from
> > > > > the
> > > > > function in ther ADDIN.
> > > > >
> > > > > "papou" wrote:
> > > > >
> > > > >> Hi Marvin
> > > > >> Use Application.run "YourAddin.xla",Argument
> > > > >>
> > > > >> HTH
> > > > >> Cordially
> > > > >> Pascal
> > > > >>
> > > > >> "Marvin" <(E-Mail Removed)> a écrit dans le message de
> > > > >> news:
> > > > >> 05F1B491-B825-4172-A943-(E-Mail Removed)...
> > > > >> >I have a function in an addin that is loaded. I seem unable to come up
> > > > >> >with
> > > > >> > the syntax in VBA code to get it to function properly.
> > > > >> >
> > > > >> > As a workbook function it is used as
> > > > >> > =topleft(r)
> > > > >> > where r is a range
> > > > >> >
> > > > >> > If I copy the code into the module, it is used as
> > > > >> >
> > > > >> > rtl=topleft(r)
> > > > >> >
> > > > >> > How do I use it without cloning the code into the module?
> > > > >> >
> > > > >> > Thanks.
> > > > >>
> > > > >>
> > > > >>
> > > >
> > > >
> > > >

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Jun 2007
That certainly is an option. But you don't _need_ to do it that way.

Randy Harmelink wrote:
>
> In order to make the functions of the add-in available like normal VBA
> functions, you need to use the menu option > Tools > References and
> add a reference to the add-in project to the VBE project. Then, you
> should be able to just do something like this in your VBA code:
>
> x = topleft(Range(r))
>
> On Jun 22, 6:46 am, Marvin <Mar...@discussions.microsoft.com> wrote:
> > I have a function in an addin that is loaded. I seem unable to come up with
> > the syntax in VBA code to get it to function properly.
> >
> > As a workbook function it is used as
> > =topleft(r)
> > where r is a range
> >
> > If I copy the code into the module, it is used as
> >
> > rtl=topleft(r)
> >
> > How do I use it without cloning the code into the module?
> >
> > Thanks.


--

Dave Peterson
 
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
Addins - Calling an addin function from within VBA code =?Utf-8?B?R3V5IE5vcm1hbmRlYXU=?= Microsoft Excel Programming 1 20th Jun 2006 07:22 PM
Call a DLL LIB function in ASP.NET (Code Behind) or VB.NET (The same code is working fine in VB 6.0) Peri Microsoft VB .NET 5 20th Jul 2005 06:37 AM
Call a DLL LIB function in ASP.NET (Code Behind) or VB.NET (The same code is working fine in VB 6.0) Peri Microsoft ASP .NET 2 20th Jul 2005 04:13 AM
How to call a function in the main program from my AddIn? Woo Mun Foong Microsoft Access 0 4th Mar 2004 09:41 AM
using a function in an addin in my vba code archangel Microsoft Excel Programming 2 6th Sep 2003 08:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:56 PM.