Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Accessing Addin from Sheet_Event Code

To conserve size, I deleted all the code but the sheet(s)_event code from my
spreadsheet, to create MyAddin. Now, from within a sheet_event, I need to
access a sub in MyAddin. Searching the help file, I found what I thought
was an explanation in the AddIn Object:

I have unsuccessfully tried setting my addin as:
1. Set wb = Workbooks("MyAddin.xla")
2. Set wb = Workbooks(AddIns("MyAddin").Name)
and then calling the sub that is in MyAddin by:
1. wb.Sub99
2. wb.Module.Sub99

How can I successfully call "Sub99", located in MyAddin, from a sheet_event?
A second question: Is it bad practice to delete most of the code from the
spreadsheet, as I have done? Would it have been better to leave it all
within the spreadsheet (and leave the spreadsheet itself to be huge)?

TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Accessing Addin from Sheet_Event Code

Application.Run "MyAddin.xla!Module1.Sub99"

If you create a reference from the workbook to myaddin, then you just call
it with

Sub99

--
Regards,
Tom Ogilvy


zSplash wrote in message
...
To conserve size, I deleted all the code but the sheet(s)_event code from

my
spreadsheet, to create MyAddin. Now, from within a sheet_event, I need to
access a sub in MyAddin. Searching the help file, I found what I thought
was an explanation in the AddIn Object:

I have unsuccessfully tried setting my addin as:
1. Set wb = Workbooks("MyAddin.xla")
2. Set wb = Workbooks(AddIns("MyAddin").Name)
and then calling the sub that is in MyAddin by:
1. wb.Sub99
2. wb.Module.Sub99

How can I successfully call "Sub99", located in MyAddin, from a

sheet_event?
A second question: Is it bad practice to delete most of the code from the
spreadsheet, as I have done? Would it have been better to leave it all
within the spreadsheet (and leave the spreadsheet itself to be huge)?

TIA




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Accessing Addin from Sheet_Event Code

Dim wb As Workbook
Set wb = Workbooks("MyAddin.xla")
Application.Run wb.Name & "!Sub99"

or a modification for workbook names with apostrophes and/or spaces, this
will work for everything:
Application.Run _
"'" & Replace(wb.Name, "'", "''") & "'!Sub99"


"zSplash" wrote in message
...
To conserve size, I deleted all the code but the sheet(s)_event code from

my
spreadsheet, to create MyAddin. Now, from within a sheet_event, I need to
access a sub in MyAddin. Searching the help file, I found what I thought
was an explanation in the AddIn Object:

I have unsuccessfully tried setting my addin as:
1. Set wb = Workbooks("MyAddin.xla")
2. Set wb = Workbooks(AddIns("MyAddin").Name)
and then calling the sub that is in MyAddin by:
1. wb.Sub99
2. wb.Module.Sub99

How can I successfully call "Sub99", located in MyAddin, from a

sheet_event?
A second question: Is it bad practice to delete most of the code from the
spreadsheet, as I have done? Would it have been better to leave it all
within the spreadsheet (and leave the spreadsheet itself to be huge)?

TIA




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Accessing Addin from Sheet_Event Code

Thanks, Tom and Tim. It works great.

st.

"Tim Zych" wrote in message
...
Dim wb As Workbook
Set wb = Workbooks("MyAddin.xla")
Application.Run wb.Name & "!Sub99"

or a modification for workbook names with apostrophes and/or spaces, this
will work for everything:
Application.Run _
"'" & Replace(wb.Name, "'", "''") & "'!Sub99"


"zSplash" wrote in message
...
To conserve size, I deleted all the code but the sheet(s)_event code

from
my
spreadsheet, to create MyAddin. Now, from within a sheet_event, I need

to
access a sub in MyAddin. Searching the help file, I found what I

thought
was an explanation in the AddIn Object:

I have unsuccessfully tried setting my addin as:
1. Set wb = Workbooks("MyAddin.xla")
2. Set wb = Workbooks(AddIns("MyAddin").Name)
and then calling the sub that is in MyAddin by:
1. wb.Sub99
2. wb.Module.Sub99

How can I successfully call "Sub99", located in MyAddin, from a

sheet_event?
A second question: Is it bad practice to delete most of the code from

the
spreadsheet, as I have done? Would it have been better to leave it all
within the spreadsheet (and leave the spreadsheet itself to be huge)?

TIA






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
Accessing the Solver Add-in in VBA BigHairyUglyGuy Excel Discussion (Misc queries) 1 April 8th 08 03:21 PM
Accessing a Function Bill Martin -- (Remove NOSPAM from address) Excel Discussion (Misc queries) 4 January 1st 05 05:46 AM
Accessing AddIn Class Modules from Client Worksheet Mark D'Agosta Excel Programming 0 October 9th 03 04:43 PM
using a function in an addin in my vba code archangel Excel Programming 2 September 6th 03 08:09 AM
Accessing the Desktop Orlando Magalhães Filho Excel Programming 1 July 15th 03 06:55 AM


All times are GMT +1. The time now is 03:18 AM.

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"