Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open another VB file and pass variables? 2

Status
Not open for further replies.

Asspin

Technical User
Jan 17, 2005
155
US
I am sure I am just forgetting something from back in school here, but I am trying to figure out how to open another VB file and pass variables.

I have the VB file setup to accept the input:
Code:
Public Sub Main(strInput as String)

The VBA calling the file is in MS Project, in case it matters.
Code:
FileOpen "C:\Documents and Settings\Dan\Desktop\Script.avsauto"

What the heck am I forgetting?

Dan
 
Hi,

"I have the VB file setup to accept the input:"

What is a VB input file? Are you also programming in VB 5 or 6?

So your application is in MS Project.

You explain absolutely nothing about your code. Where does strInput come from?

I am totally lost. Your information is sketchy. Suppose you give us a tad more specific information. Remember, no one can undersand what you are thinking unless you expressit it clearly concisely and completely.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Haha, sorry Skip, posted that right before I left work.

Basically I have a program that uses VB6 for its scripts. It is the file I need to open via the VBA from Project. I need to pass a variable from MS Project to the VB6 script when it opens. I figured I could just open the file and pass the variables like I would a module in Project, but that didn't work.

strInput should be the variable I am trying to pass from the MS Project file. I know how to open the file from Project (FileOpen "C:\Documents and Settings\Dan\Desktop\Script.avsauto") but I am at a loss as to how to pass any variables to it.

Hope that's more clear (not that it makes much sense to me either)!

Dan
 


"Basically I have a program that uses VB6 for its scripts. It is the file I need to open via the VBA from Project."

So you need to EXECUTE the VB6 program from MS Project, passing an argument?

Check out the Shell function.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Ok, I gave that a try. I can open the Windows calculator and what have you with it, but I am erroring out when I try to load the script. strLocation and strSkill are the values that need passed to Script.avsauto, but at this point I am just trying to get it to run at all. :)

I am getting "Run-time error '5': Invalid procesure call or argument" on the Shell command when I try to run this.

Code:
Sub UpdateCentreVu()
' Macro by Dan.
Dim strLocation As String, strSkill As String, RetVal
With ActiveProject.Application
    .ScreenUpdating = False
    .SelectTaskField Row:=0, Column:="Location"
    strLocation = .ActiveCell.Text
    .SelectTaskField Row:=0, Column:="Skill"
    strSkill = .ActiveCell.Text
    .SelectTaskField Row:=0, Column:="Indicators"
    .ScreenUpdating = True
End With

RetVal = Shell("C:\Script.avsauto")

If RetVal = 0 Then MsgBox "Unable to find script!" & vbNewLine & "Please contact the admin."

End Sub

Dan
 
I suspect you need to run the VB interpreter in the shell with "C:\Script.avsauto" as an argument.

_________________
Bob Rashkin
 

Can you run your script file from the command line?

Why are you using ROW=[red]0[/red]?

Are you getting the correct values into strLocation & strSkill? Use your debugger.


Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
The script does run from the command line. I am pulling values based on the row the user is currently in. The values are working fine.

Dan
 
Can it run from the command line WITHOUT arguments?

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Yeah if I just type in the file name it works fine.

Dan
 
So, what about this ?
RetVal = CreateObject("WScript.Shell").Run("C:\Script.avsauto", , True)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That does work PHV. So now my last question is... how do I pass my two variables through, using this method?

Dan
 
How you'd pass it in a command window ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I didn't, I just tested to see if I could open the file. :)

I suppose, if I have to, I can create a bunch of scripts and use a select case to pick the one that needs ran. As it stands now, the script has the select case in it to get the right variables.

Dan
 
Well I'll be, this site has everything! Thanks!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top