Shell command in VB 6

dim s1
sstring as string

s1 = Shell(sstring, vbMaximizedFocus)

this is not working.
Try opening the file using the notepad/wordpad application. it will work.

Dim tmp

tmp = Shell("notepad c:\dmm\DMM_Log_030107.txt", vbMaximizedFocus)


Somya Bhargava

ShellExecute 0&, "open", "Analysis\assgn5.xls", "", "", vbNormalFocus

I used this to call my file. and it doesn't require Excel to be called & opens your Excel file. If you need some specific file to be opened.

Somya Bhargava
So how do you open an already existing file? I am trying to use notepad to open a help text file that I have created, and I have gotten Notepad open, but I cannot figure out how to open the text file!
Opening a file with the program via shell is great, but is there any way of automatically printing the file as well?

Would love an answer, can send to engineer.div at moduplay. com. au.

Thanks in advance.
Your code solved a problem for me that I had been researching for hours. Can't tell you how much I appreciate it! - R Cooper
> How does one terminate the application after it has run for a specified time? <

If it is a VB application, check for the specified time and then call "unload me" function to close currently running form
> This works, but program(s) always load minimized, or in some cases show up on
> taskbar, but won't "restore / maximize" if clicked on...

Solution: VB 6.0
declare a variable .eg a as variant
then initialize it as
a = Shell ("Full Path of .exe",vbNormalFocus)
and then the .exe will open as maximized
You can use many other Constants available like
>Try this code it will work.<pre>
>Private Declare Function ShellExecute
>Lib _
> "shell32.dll" Alias
>"ShellExecuteA" _
> (ByVal hwnd As Long, ByVal
>lpOperation _
> As String, ByVal lpFile As String,
>ByVal _
> lpParameters As String, ByVal
>lpDirectory _
> As String, ByVal nShowCmd As Long)
>As Long
>Const SW_HIDE = 0
>Const SW_NORMAL = 1
>Const SW_MAXIMIZE = 3
>Const SW_SHOW = 5
>Const SW_MINIMIZE = 6
>Const SW_SHOWNA = 8
>Const SW_RESTORE = 9
>Const SW_MAX = 10
>Private Sub cmdExcel_Click()
>ShellExecute 0&, vbNullString, "excel",
>vbNullString, _
> vbNullString, SW_SHOWDEFAULT
>End Sub
>'in third vbnullstring arguement pass
>the file path
Can you help me out in passing the argument in the third vbnullstring so I can open an existing excel file saved as my.xls
You are calling a Microsoft Word File not the Microsoft Word Application, it should be like this

s1 = Shell("c:\program files\microsoft\excel.exe " & sstring, vbMaximizedFocus)

> dim s1
> sstring as string
> s1 = Shell(sstring, vbMaximizedFocus)
>this is not working.