Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Call Macro from PERSONAL.XLS

The public variable is in personal.xls and you're trying to return that?

If yes, then create a function in personal.xls and call that function:

Function ReturnPublicVar1Val() as string 'variant, long, ...
returnpublicvar1val = MyPublicVariableNameGoesHere
end function



jutlaux wrote:

I used your application.run suggestion and this did work as needed. Thanks!

I failed to mention that the script being called has a variable that returns
some information. When I use your suggestion the public variable that has
the information to be returned is empty. Thoughts?

Thanks again.

"Dave Peterson" wrote:

Dim pWkbk as workbook
set pwkbk = workbooks("Personal.xls")
application.run "'" & pwkb.name & "'!macronamehere", "parm1", "parm2"

or if you're returning a value from a function:

dim res as string 'or variant or long or ...
res = application.run("'" & pwkb.name & "'!macronamehere", "parm1", "parm2")

You could also create a reference to this personal.xls workbook and call it just
like it was built into excel.

Tools|references
(but give the personal.xls's project a nice unique name (not VBAProject).

ps.

If you're using a function living in personal.xls inside a cell:
=personal.xls!functionnamehere(a1,b1,c1)

or save the file as an addin (*.xla) and use it in the cell like it's built into
excel:
=functionnamehere(a1,b1,c1)





jutlaux wrote:

I have a macro that is stored in my personal.xls that I would like to be able
to call from another workbook. I have the macro stored in a standard code
module and have it defined as a public type, but when i go to call it from
another workbook I get:

"Compile error:

Sub or Function not defined"

Aside from coping the entire script into the new workbook is there a way to
call a script stored in personal.xls from another workbook?

Thanks!


--

Dave Peterson


--

Dave Peterson
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Call Macro from PERSONAL.XLS

Or add a reference to that personal.xls workbook and just use the variable like
it's local to your project.

Dave Peterson wrote:

The public variable is in personal.xls and you're trying to return that?

If yes, then create a function in personal.xls and call that function:

Function ReturnPublicVar1Val() as string 'variant, long, ...
returnpublicvar1val = MyPublicVariableNameGoesHere
end function

jutlaux wrote:

I used your application.run suggestion and this did work as needed. Thanks!

I failed to mention that the script being called has a variable that returns
some information. When I use your suggestion the public variable that has
the information to be returned is empty. Thoughts?

Thanks again.

"Dave Peterson" wrote:

Dim pWkbk as workbook
set pwkbk = workbooks("Personal.xls")
application.run "'" & pwkb.name & "'!macronamehere", "parm1", "parm2"

or if you're returning a value from a function:

dim res as string 'or variant or long or ...
res = application.run("'" & pwkb.name & "'!macronamehere", "parm1", "parm2")

You could also create a reference to this personal.xls workbook and call it just
like it was built into excel.

Tools|references
(but give the personal.xls's project a nice unique name (not VBAProject).

ps.

If you're using a function living in personal.xls inside a cell:
=personal.xls!functionnamehere(a1,b1,c1)

or save the file as an addin (*.xla) and use it in the cell like it's built into
excel:
=functionnamehere(a1,b1,c1)





jutlaux wrote:

I have a macro that is stored in my personal.xls that I would like to be able
to call from another workbook. I have the macro stored in a standard code
module and have it defined as a public type, but when i go to call it from
another workbook I get:

"Compile error:

Sub or Function not defined"

Aside from coping the entire script into the new workbook is there a way to
call a script stored in personal.xls from another workbook?

Thanks!

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
Call sub from Personal.xls don Excel Programming 6 June 23rd 08 06:23 AM
How to Call Functions in the Personal Workbook? SteveM Excel Programming 1 December 18th 07 03:07 PM
Custom button to call a macro in Personal David Walker Excel Programming 1 July 1st 06 11:45 PM
Call a sub statement in "Personal Macro Workbook" from "ThisWorkbo QC Coug Excel Programming 1 August 26th 05 07:09 PM
Personal macro workbook and personal.xls John Kilkenny Excel Discussion (Misc queries) 1 June 14th 05 09:43 PM


All times are GMT +1. The time now is 05:01 PM.

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

About Us

"It's about Microsoft Excel"