We help IT Professionals succeed at work.

Calling another program (.exe) to be run on VB

FaRZ
FaRZ asked
on

how am i going to call another program for (e.g winzip 8.0) to be run on VB?

how the winzip can call another file to zip on?.. do we have to write another program that make the winzip browsing to get the file?

that's all, thanks
Comment
Watch Question

Commented:
Try the shell() function.  

Or, use the windows scripting host.
<----- Code Begin ----->

  Dim wshShell
  Set wshShell = CreateObject("WScript.Shell")
  wshShell.Run myrs!path, SW_HIDE, True
  Set wshShell = Nothing ' When you are all done

<----- Code End ----->

Where:

myrs!Path = The FilePath to your executable

SW_HIDE = One of the following constants:
  Const SW_HIDE = 0
  Const SW_SHOWNORMAL = 1
  Const SW_SHOWMINIMIZED = 2
  Const SW_SHOWMAXIMIZED = 3
  Const SW_SHOWNOACTIVE = 4
  Const SW_SHOW = 5
  Const SW_MINIMIZE = 6
  Const SW_SHOWMINNOACTIVE = 7
  Const SW_SHOWNA = 8
  Const SW_RESTORE = 9

True = a boolean True False as to whether or Not you want to wait for Execution to finish.

Good Luck!
try something like this:

Dim x
Dim strFileName as string

strFileName = "myfile.zip"
x = shell ("C:\program files\winzip\winzip.exe " +  strFileName)
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:
If problem is zip files, you could use this excelent/free tool:
http://www.vbaccelerator.com/codelib/zip/unzip.htm
Richie_SimonettiIT Operations
CERTIFIED EXPERT

Commented:

Author

Commented:
KMAN..

how am i going to set the path to the myrs!path?.. when i typed in myrs!path, the vb said.. "! expected end of statement"..

the other thing, SW_HIDE.. do i have to choose any of those constants?.. where should i write it?.. do i have to change this:

wshShell.Run myrs!path, SW_HIDE, True

to for example, this:

wshShell.Run myrs!path, Const SW_SHOWMAXIMIZED = 3, True

sorry.. so many things bother me..

thanks

FaRZ

Author

Commented:
Crash2100..

i tried your suggestion code, it works but it can only call the file but do not work properly. actually, i realize now  that the file is not in exe, but .bat. in fact, the file is calling another .exe file in its own program.

by the way, i'm working on it.

thanks.

p/s: its not a zip file though.. never mind then..

FaRZ

Author

Commented:
crash2100..

i got it.. thanks a lot.. it works!!!

by the way.. thanks to KMAN & Richie too.. really appreciate your kindness..

bye..

FaRZ

Author

Commented:
even though the code that you gave me is not exactly into my problem, but with slight alteration, it works, thanks a lot.

FaRZ

Explore More ContentExplore courses, solutions, and other research materials related to this topic.