LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Argument value, application.run

Neal, There are a couple of points in you various call:

'Application.Run (MacName, Ver) ??? compile error: Expected: =

This is expect, as you are using the braces ..(....).., so Excel expects you
to assign the return value to a variable; which you are not doing here.
But this will work:
Application.Run MacName, Ver

According to the help:
Objects passed as arguments to the macro are converted to values (by
applying the Value property to the object). This means that you cannot pass
objects to macros by using the Run method.

Whilst it not explicit about normal data type, it seem that you cannot pass
any argument ByRef with .Run, only ByVal. Hence your sub routine would never
return to expected value.
If in doubt, check the help for the difference between ByRef (the default in
VB/VBA) and ByVal in passing arguments.

NickHK

"Neal Zimm" wrote in message
...
Hi -
I don't know where to go next in getting the value to return from a Sub
executed from one Wbk to another.
I got The function to return the correct value.
Running the Sub gets the correct debug.print, But the returned argument

is
either the same as the function or blank in the final examples below.
Why ?
Thanks,
Neal

' IN 1125 Wbk, Which is ACTIVE
Function zRmVerF(Dummy) As String
zRmVerF = "v01.03.00"
Debug.Print zRmVerF
End Function

'Sub in same as above
Sub zRmVerSub(Ver As String)
Ver = "vRm.Ver.Sub"
Debug.Print Ver
End Sub

' executed from VBE in personal.xls
Sub RUN_MACRO_WAYS()
Dim Ver As String, MacName As String
'Ver = Application.Run("'d1125.xls'!zRmVerF", "")
'MsgBox Ver 'WORKS prints and value passed

Dim WbkNa As String
WbkNa = ActiveWorkbook.Name
MacName = "zRmVerF"
Ver = Application.Run(WbkNa & "!" & MacName, "")
MsgBox Ver 'WORKS prints and value passed


MacName = WbkNa & "!" & "zRmVerSub"
'Application.Run (MacName, Ver) ??? compile error: Expected: =

'Application.Run MacName, Ver 'debug.print good,
'MsgBox Ver 'shows v01.03.00 from function, NOT vRm.Ver.Sub as expected


Dim DiffVer As String
Application.Run MacName, DiffVer 'debug.print is good
MsgBox DiffVer, , "DiffVer" 'no value for DiffVer ???
End Sub
--
Neal Z



 
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
difference application.quit & application.close Pierre via OfficeKB.com[_2_] Excel Programming 4 November 8th 05 07:55 PM
Application.GetOpenFilename vs Application.Dialogs(xlDialogsOpen) Paul Martin Excel Programming 5 August 5th 05 04:44 PM
Replace application.RTD property by Application.RTDServers collect John.Greenan Excel Programming 1 July 7th 05 02:05 PM
Function (array argument, range argument, string argument) vba Witek[_2_] Excel Programming 3 April 24th 05 03:12 PM
macro to close excel application other than application.quit mary Excel Programming 1 September 14th 04 03:43 PM


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

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

About Us

"It's about Microsoft Excel"