Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Application.Run error

Hi,

I'm using the following code to do a call for a function in a workbook
called "Code"

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub

This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" is in a workbook that holds of the codes I wish to use
in my project.(different workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Application.Run error

there are certain words that you shouldn't use as the name of a module
or code or function ........ "code" is one of them.
try renaming your function to something like MyCode and try again.
:)
susan



On Oct 23, 3:17*pm, wrote:
Hi,

I'm using the following code to do a call for a function in a workbook
called "Code"

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
* Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub

This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" *is in a workbook that holds of the codes I wish to use
in my project.(different *workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Application.Run error

in theory i'm right, although i did misread your post. try renaming
your workbook - anything but code.xls.
:)
susan


On Oct 23, 3:25*pm, Susan wrote:
there are certain words that you shouldn't use as the name of a module
or code or function ........ "code" is one of them.
try renaming your function to something like MyCode and try again.
:)
susan

On Oct 23, 3:17*pm, wrote:



Hi,


I'm using the following code to do a call for a function in a workbook
called "Code"


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
* Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub


This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" *is in a workbook that holds of the codes I wish to use
in my project.(different *workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.


Thanks- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Application.Run error

On Oct 23, 2:25*pm, Susan wrote:
there are certain words that you shouldn't use as the name of a module
or code or function ........ "code" is one of them.
try renaming your function to something like MyCode and try again.
:)
susan

On Oct 23, 3:17*pm, wrote:

Hi,


I'm using the following code to do a call for a function in a workbook
called "Code"


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
* Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub


This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" *is in a workbook that holds of the codes I wish to use
in my project.(different *workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.


Thanks


Thanks for the reply.
I renamed the "Code" to "MyCode" and still received the error Macro
cannot be found.
I also re-named the Function ModuleWorksheet_SelectionChange(Target)
to
Worksheet_SelectionChange(Target)
Still received the error.
The project workbook holds the all of the call procedures.
The "MyCode" workbooks holds all of the Functions I wish to use.
All of the "Function" are declared as "Public" in a Module.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Application.Run error

You know the sheet codename/module name that should be called, right.

I used Sheet2 (just to be different).

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim wkbk As Workbook
Set wkbk = Workbooks("Code.xls")
Application.Run _
"'" & wkbk.Name & "'!sheet2.Worksheet_SelectionChange", Target
End Sub



wrote:

Hi,

I'm using the following code to do a call for a function in a workbook
called "Code"

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub

This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" is in a workbook that holds of the codes I wish to use
in my project.(different workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.

Thanks


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Application.Run error

With App.Run you can only call a procedures in a normal module. Also, you
can only pass values as arguments. So, even if you were calling a normal
routine you want not be able to pass the expected range object (your way
would pass its default value property).

In a normal module in Code.xls include a macro like this -

Sub myMacro(sAddr As String)
Dim rng As Range

On Error GoTo errH
Set rng = Range(sAddr) ' recreate the range object
' do stuff here
MsgBox rng(1).Value

Exit Sub
errH:
MsgBox Err.Description

End Sub

In your other workbook call the macro and pass the full address of the range
Target

Application.Run "Code.xls!myMacro", Target.Address(external:=True)

Regards,
Peter T


wrote in message
...
Hi,

I'm using the following code to do a call for a function in a workbook
called "Code"

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub

This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" is in a workbook that holds of the codes I wish to use
in my project.(different workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.

Thanks



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Application.Run error

ok. sorry, i don't know, then. maybe this thread will help

http://groups.google.com/group/micro...43b70e2c6cc712

sorry!
susan


On Oct 23, 3:41*pm, wrote:
On Oct 23, 2:25*pm, Susan wrote:





there are certain words that you shouldn't use as the name of a module
or code or function ........ "code" is one of them.
try renaming your function to something like MyCode and try again.
:)
susan


On Oct 23, 3:17*pm, wrote:


Hi,


I'm using the following code to do a call for a function in a workbook
called "Code"


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
* Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub


This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" *is in a workbook that holds of the codes I wish to use
in my project.(different *workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.


Thanks


Thanks for the reply.
I renamed the "Code" to "MyCode" and still received the error Macro
cannot be found.
I also re-named the Function ModuleWorksheet_SelectionChange(Target)
to
Worksheet_SelectionChange(Target)
Still received the error.
The project workbook holds the all of the call procedures.
The "MyCode" workbooks holds all of the Functions I wish to use.
All of the "Function" are declared as "Public" in a Module.- Hide quoted text -

- Show quoted text -


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Application.Run error

This won't work.

Target is still a range that points to the cells that changed in the original
worksheet. (I don't think that's what you want.)

Maybe...

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim wks As Worksheet

Set wks = Workbooks("code.xls").Worksheets("sheet2")

With wks
Application.Run "'" & .Parent.Name & "'!" _
& .CodeName & ".Worksheet_SelectionChange", .Range(Target.Address)
End With

End Sub

Dave Peterson wrote:

You know the sheet codename/module name that should be called, right.

I used Sheet2 (just to be different).

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim wkbk As Workbook
Set wkbk = Workbooks("Code.xls")
Application.Run _
"'" & wkbk.Name & "'!sheet2.Worksheet_SelectionChange", Target
End Sub

wrote:

Hi,

I'm using the following code to do a call for a function in a workbook
called "Code"

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub

This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" is in a workbook that holds of the codes I wish to use
in my project.(different workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.

Thanks


--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Application.Run error

Having read Dave's, sheepishly I must request please ignore mine !

(must have had OnTime in mind)

Regards,
Peter T

"Peter T" <peter_t@discussions wrote in message
...
With App.Run you can only call a procedures in a normal module. Also, you
can only pass values as arguments. So, even if you were calling a normal
routine you want not be able to pass the expected range object (your way
would pass its default value property).

In a normal module in Code.xls include a macro like this -

Sub myMacro(sAddr As String)
Dim rng As Range

On Error GoTo errH
Set rng = Range(sAddr) ' recreate the range object
' do stuff here
MsgBox rng(1).Value

Exit Sub
errH:
MsgBox Err.Description

End Sub

In your other workbook call the macro and pass the full address of the
range Target

Application.Run "Code.xls!myMacro", Target.Address(external:=True)

Regards,
Peter T


wrote in message
...
Hi,

I'm using the following code to do a call for a function in a workbook
called "Code"

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub

This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" is in a workbook that holds of the codes I wish to use
in my project.(different workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.

Thanks





  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Application.Run error

On Oct 23, 3:02*pm, "Peter T" <peter_t@discussions wrote:
With App.Run you can only call a procedures in a normal module. Also, you
can only pass values as arguments. So, even if you were calling a normal
routine you want not be able to pass the expected range object (your way
would pass its default value property).

In a normal module in Code.xls include a macro like this -

Sub myMacro(sAddr As String)
Dim rng As Range

* * On Error GoTo errH
* * Set rng = Range(sAddr) ' recreate the range object
* * ' do stuff here
* * MsgBox rng(1).Value

* * Exit Sub
errH:
* * MsgBox Err.Description

End Sub

In your other workbook call the macro and pass the full address of the range
Target

Application.Run "Code.xls!myMacro", Target.Address(external:=True)

Regards,
Peter T

wrote in message

...

Hi,


I'm using the following code to do a call for a function in a workbook
called "Code"


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
*Application.Run ("Code.xls!ModuleWorksheet_SelectionChange(Target) ")
End Sub


This code is in my primary project. However I receive an error that
say's the Macro cannot be found.
The "Code.xls" *is in a workbook that holds of the codes I wish to use
in my project.(different *workbook)
I've used various formats for the above code found on this forum.
Using Excel 2003 windows XP
Any help would be great.


Thanks


Ok,

Thanks to all.
I tried "Daves" approach and it gets me to the "Function" I'm looking
for.
However I did remove the "sheet1" in his code.
Once again the forum came through.

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
runtime error '1004' application or object defined error Janis Excel Programming 4 November 18th 09 03:01 PM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 05:41 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"