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
|