Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Vbscript and VBA

Greetings, Is it possible to launch a script from vba?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Vbscript and VBA

Use shell function

Shell(pathname[,windowstyle])



"Office_Novice" wrote:

Greetings, Is it possible to launch a script from vba?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Vbscript and VBA

Tryied that it threw a Run Time Error: Invaild procedure


"Joel" wrote:

Use shell function

Shell(pathname[,windowstyle])



"Office_Novice" wrote:

Greetings, Is it possible to launch a script from vba?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Vbscript and VBA

How do you normally run the script?

You provbably have to run the VB and pass the VB apllication the script in a
command line option.

shell("c:\program files\Vb\vb.exe c:\user\myscript")
something like the line above where vb.exe is the application. You need
tospecify in the command line the option for a script input.

"Office_Novice" wrote:

Tryied that it threw a Run Time Error: Invaild procedure


"Joel" wrote:

Use shell function

Shell(pathname[,windowstyle])



"Office_Novice" wrote:

Greetings, Is it possible to launch a script from vba?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Vbscript and VBA

Any idea how to pass the script's path from VBA to the command line?

"Joel" wrote:

How do you normally run the script?

You provbably have to run the VB and pass the VB apllication the script in a
command line option.

shell("c:\program files\Vb\vb.exe c:\user\myscript")
something like the line above where vb.exe is the application. You need
tospecify in the command line the option for a script input.

"Office_Novice" wrote:

Tryied that it threw a Run Time Error: Invaild procedure


"Joel" wrote:

Use shell function

Shell(pathname[,windowstyle])



"Office_Novice" wrote:

Greetings, Is it possible to launch a script from vba?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Vbscript and VBA

A VBA main subroutine (SUB) in VBA cannot have any parameters. The main VBA
sub can call other subroutine and functions passing parameters. The path
must come use other methods then passing parameters

1) You may want to put the script name on the worksheet
2) You can browse for the script using getfilenameopen method
3) You can hard code the filename in the VBA code.
4) You can search for a file name using the DIR() method using a wildcard

Folder = "c:\temp\"
FName = dir(Folder & "*.txt")
do while FName < ""
'enter you code here
FName = dir()
loop



"Office_Novice" wrote:

Any idea how to pass the script's path from VBA to the command line?

"Joel" wrote:

How do you normally run the script?

You provbably have to run the VB and pass the VB apllication the script in a
command line option.

shell("c:\program files\Vb\vb.exe c:\user\myscript")
something like the line above where vb.exe is the application. You need
tospecify in the command line the option for a script input.

"Office_Novice" wrote:

Tryied that it threw a Run Time Error: Invaild procedure


"Joel" wrote:

Use shell function

Shell(pathname[,windowstyle])



"Office_Novice" wrote:

Greetings, Is it possible to launch a script from vba?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Vbscript and VBA

Thanks for the Help Joel. Here was my solution, I created a .bat file with
the full path of the script. Then i uesd the Shell function in VBA to launch
the batch file thus running the script.

"Joel" wrote:

A VBA main subroutine (SUB) in VBA cannot have any parameters. The main VBA
sub can call other subroutine and functions passing parameters. The path
must come use other methods then passing parameters

1) You may want to put the script name on the worksheet
2) You can browse for the script using getfilenameopen method
3) You can hard code the filename in the VBA code.
4) You can search for a file name using the DIR() method using a wildcard

Folder = "c:\temp\"
FName = dir(Folder & "*.txt")
do while FName < ""
'enter you code here
FName = dir()
loop



"Office_Novice" wrote:

Any idea how to pass the script's path from VBA to the command line?

"Joel" wrote:

How do you normally run the script?

You provbably have to run the VB and pass the VB apllication the script in a
command line option.

shell("c:\program files\Vb\vb.exe c:\user\myscript")
something like the line above where vb.exe is the application. You need
tospecify in the command line the option for a script input.

"Office_Novice" wrote:

Tryied that it threw a Run Time Error: Invaild procedure


"Joel" wrote:

Use shell function

Shell(pathname[,windowstyle])



"Office_Novice" wrote:

Greetings, Is it possible to launch a script from vba?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Vbscript and VBA

the shell command doesn't execute the exe or bat file in the user
environment. the shell doesn't search for the user file usingf the windows
PATH property. The code below will find any executable in the user path

Sub FindMyFile()

Filename = "excel.exe"
Path = Environ("Path")
splitPath = Split(Path, ";")
Found = False
For Each Folder In splitPath
FName = Dir(Folder & "\" & Filename)
If FName < "" Then
MsgBox ("File found in Folder : " & Folder)
Found = True
End If

Next Folder

End Sub

"Office_Novice" wrote:

Thanks for the Help Joel. Here was my solution, I created a .bat file with
the full path of the script. Then i uesd the Shell function in VBA to launch
the batch file thus running the script.

"Joel" wrote:

A VBA main subroutine (SUB) in VBA cannot have any parameters. The main VBA
sub can call other subroutine and functions passing parameters. The path
must come use other methods then passing parameters

1) You may want to put the script name on the worksheet
2) You can browse for the script using getfilenameopen method
3) You can hard code the filename in the VBA code.
4) You can search for a file name using the DIR() method using a wildcard

Folder = "c:\temp\"
FName = dir(Folder & "*.txt")
do while FName < ""
'enter you code here
FName = dir()
loop



"Office_Novice" wrote:

Any idea how to pass the script's path from VBA to the command line?

"Joel" wrote:

How do you normally run the script?

You provbably have to run the VB and pass the VB apllication the script in a
command line option.

shell("c:\program files\Vb\vb.exe c:\user\myscript")
something like the line above where vb.exe is the application. You need
tospecify in the command line the option for a script input.

"Office_Novice" wrote:

Tryied that it threw a Run Time Error: Invaild procedure


"Joel" wrote:

Use shell function

Shell(pathname[,windowstyle])



"Office_Novice" wrote:

Greetings, Is it possible to launch a script from vba?

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
borders in VBScript [email protected] Excel Programming 1 June 11th 08 05:00 PM
Please help with ADO and VBScript! jenhu[_2_] Excel Programming 1 March 23rd 06 05:06 PM
vbscript question... rosen Excel Programming 1 December 28th 04 10:58 PM
VBscript sebastienm Excel Programming 0 September 22nd 04 08:24 PM
VBscript raji Excel Programming 0 September 22nd 04 08:03 PM


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