Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problems calling a procedure in another application

I am having difficulty sending arguments while calling a
procedure in another application. I can run the
reflections_macro in the Reflections application by using
this command:

R2WINObject.RunMacro "reflections_macro"

When Excel calls this macro, it asks the user to input a
starting and ending date. Instead, I want to streamline
this macro by eliminating the need for user input and
have Excel send the start and end dates, but this
modified command does not work:

R2WINObject.RunMacro "reflections_macro", start_date,
end_date

I have tried numerous variations of the line above to get
it to work but to no avail. Could someone suggest the
proper code? I know it must be something easy, but I am
a novice. Thanks in advance!

More complete code:

Sub Run_Reflections_from_Excel()
Dim R2WINObject As Object
Dim xlApp As Object
Dim start_date As Date
Dim end_date As Date

startdate = Range("start_date").Value
enddate = Range("end_date").Value
Set xlApp = ActiveWorkbook

Set R2WINObject = GetObject("R2WIN")
R2WINObject.Visible = True
R2WINObject.RunMacro "reflections_macro", startdate,
enddate

xlApp.Application.Visible = True
End Sub


In Reflections:
Sub reflections_macro(ByVal startdate, ByVal enddate)
Dim startdate As Date
Dim enddate As Date

num_of_months = DateDiff("m", startdate, enddate)

....etc...
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problems calling a procedure in another application

For :R2WINObject.RunMacro "reflections_macro", start_date,
end_date
You might try :
R2WINObject.Run Macro:="reflections_macro", Arg1:=start_date, Arg2:=end_date

Terrance Rebello

"msk19" wrote:

I am having difficulty sending arguments while calling a
procedure in another application. I can run the
reflections_macro in the Reflections application by using
this command:

R2WINObject.RunMacro "reflections_macro"

When Excel calls this macro, it asks the user to input a
starting and ending date. Instead, I want to streamline
this macro by eliminating the need for user input and
have Excel send the start and end dates, but this
modified command does not work:

R2WINObject.RunMacro "reflections_macro", start_date,
end_date

I have tried numerous variations of the line above to get
it to work but to no avail. Could someone suggest the
proper code? I know it must be something easy, but I am
a novice. Thanks in advance!

More complete code:

Sub Run_Reflections_from_Excel()
Dim R2WINObject As Object
Dim xlApp As Object
Dim start_date As Date
Dim end_date As Date

startdate = Range("start_date").Value
enddate = Range("end_date").Value
Set xlApp = ActiveWorkbook

Set R2WINObject = GetObject("R2WIN")
R2WINObject.Visible = True
R2WINObject.RunMacro "reflections_macro", startdate,
enddate

xlApp.Application.Visible = True
End Sub


In Reflections:
Sub reflections_macro(ByVal startdate, ByVal enddate)
Dim startdate As Date
Dim enddate As Date

num_of_months = DateDiff("m", startdate, enddate)

....etc...
End Sub

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
Calling procedure when leaving cell jeffP Excel Worksheet Functions 5 February 9th 06 08:59 AM
VBA question - calling Procedure from userform ajliaks[_3_] Excel Programming 2 April 14th 04 09:11 PM
calling a stored procedure on MS SQL Server within MS Excel 2000 Witold Domienik Excel Programming 0 March 2nd 04 10:47 AM
Calling a .Net Procedure from a Macro Scott Eguires Excel Programming 0 December 10th 03 10:35 PM
Calling a Custom Function within a Procedure [email protected] Excel Programming 1 November 16th 03 03:51 AM


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