PC Review


Reply
Thread Tools Rate Thread

calling a user defined add-in

 
 
mike allen
Guest
Posts: n/a
 
      28th Jan 2007
can i "call" a subroutine that is held in an add-in? all i know i can do
pertains to functions (not sub's): i can type, in a cell on a spreadsheet,
=myfuntion(a,b) and it will return c in that cell.
i want the equivalent of hitting a user-created button that i created
(forms, button icon, referencing a subroutine in the list). the only
difference is my subroutine (not function) will be within an add-in, not
within a module.
is this possible? thanks


 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      28th Jan 2007
Mike,

Procedures of any sort, in an add-in or not, cannot change ANYTHING in the
Excel environment when called directly or indirectly from a worksheet cell.
If you just want to call a sub in the AddIn from other VBA code (not from a
worksheet cell), use the Run method. E.g.,

Application.Run "MyAddIn.xla!MyMacro"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"mike allen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> can i "call" a subroutine that is held in an add-in? all i know i can do
> pertains to functions (not sub's): i can type, in a cell on a spreadsheet,
> =myfuntion(a,b) and it will return c in that cell.
> i want the equivalent of hitting a user-created button that i created
> (forms, button icon, referencing a subroutine in the list). the only
> difference is my subroutine (not function) will be within an add-in, not
> within a module.
> is this possible? thanks
>



 
Reply With Quote
 
mike allen
Guest
Posts: n/a
 
      28th Jan 2007
thanks for all of your help. i just can't get it to work for some reason.
it keeps telling me "The macro 'mike.xla!mike' cannot be found." i called
everything "mike" so as to avoid picking the wrong thing. the xla is there
and is loaded and contains a sub 'mike()' that simply has a msgbox. thx
"Chip Pearson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Mike,
>
> Procedures of any sort, in an add-in or not, cannot change ANYTHING in the
> Excel environment when called directly or indirectly from a worksheet
> cell. If you just want to call a sub in the AddIn from other VBA code (not
> from a worksheet cell), use the Run method. E.g.,
>
> Application.Run "MyAddIn.xla!MyMacro"
>
>
> --
> Cordially,
> Chip Pearson
> Microsoft MVP - Excel
> Pearson Software Consulting, LLC
> www.cpearson.com
> (email address is on the web site)
>
> "mike allen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> can i "call" a subroutine that is held in an add-in? all i know i can do
>> pertains to functions (not sub's): i can type, in a cell on a
>> spreadsheet, =myfuntion(a,b) and it will return c in that cell.
>> i want the equivalent of hitting a user-created button that i created
>> (forms, button icon, referencing a subroutine in the list). the only
>> difference is my subroutine (not function) will be within an add-in, not
>> within a module.
>> is this possible? thanks
>>

>
>



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      28th Jan 2007
Try naming the macro something else. And if you used Mike as the Module name,
rename that to something unique, too:

Mike.xla (addin name)
ModMike (module name)
MacMike (macro name)

application.run "mike.xla!modmike.macmike"
or
application.run "mike.xla!macmike"

If that doesn't help, share the line you tried.



mike allen wrote:
>
> thanks for all of your help. i just can't get it to work for some reason.
> it keeps telling me "The macro 'mike.xla!mike' cannot be found." i called
> everything "mike" so as to avoid picking the wrong thing. the xla is there
> and is loaded and contains a sub 'mike()' that simply has a msgbox. thx
> "Chip Pearson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Mike,
> >
> > Procedures of any sort, in an add-in or not, cannot change ANYTHING in the
> > Excel environment when called directly or indirectly from a worksheet
> > cell. If you just want to call a sub in the AddIn from other VBA code (not
> > from a worksheet cell), use the Run method. E.g.,
> >
> > Application.Run "MyAddIn.xla!MyMacro"
> >
> >
> > --
> > Cordially,
> > Chip Pearson
> > Microsoft MVP - Excel
> > Pearson Software Consulting, LLC
> > www.cpearson.com
> > (email address is on the web site)
> >
> > "mike allen" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> can i "call" a subroutine that is held in an add-in? all i know i can do
> >> pertains to functions (not sub's): i can type, in a cell on a
> >> spreadsheet, =myfuntion(a,b) and it will return c in that cell.
> >> i want the equivalent of hitting a user-created button that i created
> >> (forms, button icon, referencing a subroutine in the list). the only
> >> difference is my subroutine (not function) will be within an add-in, not
> >> within a module.
> >> is this possible? thanks
> >>

> >
> >


--

Dave Peterson
 
Reply With Quote
 
mike allen
Guest
Posts: n/a
 
      28th Jan 2007
unbelievable! i got it to work by changing the name of the subroutine. one
thing i noticed is i can access the .xla (w/ password) directly in the vb
editor where modules typically are found. is this normal or can i make it
more difficult to even find the (password protected) .xla? i am worried
about security. either way, this is great. thanks so much to all who
assisted.
"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Try naming the macro something else. And if you used Mike as the Module
> name,
> rename that to something unique, too:
>
> Mike.xla (addin name)
> ModMike (module name)
> MacMike (macro name)
>
> application.run "mike.xla!modmike.macmike"
> or
> application.run "mike.xla!macmike"
>
> If that doesn't help, share the line you tried.
>
>
>
> mike allen wrote:
>>
>> thanks for all of your help. i just can't get it to work for some
>> reason.
>> it keeps telling me "The macro 'mike.xla!mike' cannot be found." i
>> called
>> everything "mike" so as to avoid picking the wrong thing. the xla is
>> there
>> and is loaded and contains a sub 'mike()' that simply has a msgbox. thx
>> "Chip Pearson" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Mike,
>> >
>> > Procedures of any sort, in an add-in or not, cannot change ANYTHING in
>> > the
>> > Excel environment when called directly or indirectly from a worksheet
>> > cell. If you just want to call a sub in the AddIn from other VBA code
>> > (not
>> > from a worksheet cell), use the Run method. E.g.,
>> >
>> > Application.Run "MyAddIn.xla!MyMacro"
>> >
>> >
>> > --
>> > Cordially,
>> > Chip Pearson
>> > Microsoft MVP - Excel
>> > Pearson Software Consulting, LLC
>> > www.cpearson.com
>> > (email address is on the web site)
>> >
>> > "mike allen" <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> >> can i "call" a subroutine that is held in an add-in? all i know i can
>> >> do
>> >> pertains to functions (not sub's): i can type, in a cell on a
>> >> spreadsheet, =myfuntion(a,b) and it will return c in that cell.
>> >> i want the equivalent of hitting a user-created button that i created
>> >> (forms, button icon, referencing a subroutine in the list). the only
>> >> difference is my subroutine (not function) will be within an add-in,
>> >> not
>> >> within a module.
>> >> is this possible? thanks
>> >>
>> >
>> >

>
> --
>
> Dave Peterson



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      28th Jan 2007
You can protect the project by:

Open the VBE
select the project
tools|VBAProject properties|Protection tab

Give it a password.

This will protect your code from casual intruders--not the dedicated.

mike allen wrote:
>
> unbelievable! i got it to work by changing the name of the subroutine. one
> thing i noticed is i can access the .xla (w/ password) directly in the vb
> editor where modules typically are found. is this normal or can i make it
> more difficult to even find the (password protected) .xla? i am worried
> about security. either way, this is great. thanks so much to all who
> assisted.
> "Dave Peterson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Try naming the macro something else. And if you used Mike as the Module
> > name,
> > rename that to something unique, too:
> >
> > Mike.xla (addin name)
> > ModMike (module name)
> > MacMike (macro name)
> >
> > application.run "mike.xla!modmike.macmike"
> > or
> > application.run "mike.xla!macmike"
> >
> > If that doesn't help, share the line you tried.
> >
> >
> >
> > mike allen wrote:
> >>
> >> thanks for all of your help. i just can't get it to work for some
> >> reason.
> >> it keeps telling me "The macro 'mike.xla!mike' cannot be found." i
> >> called
> >> everything "mike" so as to avoid picking the wrong thing. the xla is
> >> there
> >> and is loaded and contains a sub 'mike()' that simply has a msgbox. thx
> >> "Chip Pearson" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > Mike,
> >> >
> >> > Procedures of any sort, in an add-in or not, cannot change ANYTHING in
> >> > the
> >> > Excel environment when called directly or indirectly from a worksheet
> >> > cell. If you just want to call a sub in the AddIn from other VBA code
> >> > (not
> >> > from a worksheet cell), use the Run method. E.g.,
> >> >
> >> > Application.Run "MyAddIn.xla!MyMacro"
> >> >
> >> >
> >> > --
> >> > Cordially,
> >> > Chip Pearson
> >> > Microsoft MVP - Excel
> >> > Pearson Software Consulting, LLC
> >> > www.cpearson.com
> >> > (email address is on the web site)
> >> >
> >> > "mike allen" <(E-Mail Removed)> wrote in message
> >> > news:(E-Mail Removed)...
> >> >> can i "call" a subroutine that is held in an add-in? all i know i can
> >> >> do
> >> >> pertains to functions (not sub's): i can type, in a cell on a
> >> >> spreadsheet, =myfuntion(a,b) and it will return c in that cell.
> >> >> i want the equivalent of hitting a user-created button that i created
> >> >> (forms, button icon, referencing a subroutine in the list). the only
> >> >> difference is my subroutine (not function) will be within an add-in,
> >> >> not
> >> >> within a module.
> >> >> is this possible? thanks
> >> >>
> >> >
> >> >

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


--

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
Excel User Defined function calling RTD raoden.ss@gmail.com Microsoft Excel Programming 0 31st Mar 2008 11:34 PM
Excel User Defined function calling RTD Siva Microsoft Excel Programming 1 31st Mar 2008 04:03 PM
Calling user-defined function from adp Sara4 Microsoft Access 1 13th Dec 2007 02:05 PM
Calling Excel user defined function from C# =?Utf-8?B?U3RhbmxleQ==?= Microsoft Excel Programming 0 26th Jun 2006 02:16 PM
Calling user defined function from C/C++ Ravil Microsoft Excel Programming 0 24th Apr 2006 06:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 PM.