Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

A question on Shell function

Posted on 1998-12-29
3
Medium Priority
?
189 Views
Last Modified: 2010-05-03
hi,
I make .exe for an application and use Shell to activate it
in a menu option. The application is activated but is minimised. I check the windowstate of the form and it's Normal.

Please advise how i can activate the application and make it
normal instead of minimised?

Thanks.
Andrea
0
Comment
Question by:tanmh
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
hddp666 earned 40 total points
ID: 1453136
When you call the program using the shell function, make sure that you include the windowstyle argument. It's optional, but the default is the window minimized. Here is the syntax:

Dim r as long ' value returned by program
r = Shell(pathname[,windowstyle])
r = Shell(C:\program.exe, 1)

pathname = "c:\windows\notepad.exe c:\My Documents\resume.txt"

This will open resume.txt using notepad.exe

pathname = "c:\applications\MyProgram.exe"

This will run MyProgram.exe


windowstyle value      window state upon execution

0      Window is hidden and focus is passed to the hidden window.
1      Window has focus and is restored to its original size and position.
2      Window is displayed minimized (taskbar icon) with focus.
3      Window is maximized with focus.
4      Window is restored to its most recent size and position. The currently active window remains active.
6      Window is displayed as an icon. Current window remains active.

vbHide                      0      
vbNormalFocus              1      
vbMinimizedFocus      2      
vbMaximizedFocus      3      
vbNormalNoFocus              4      
<NONE>                 <5>
vbMinimizedNoFocus      6


0
 

Author Comment

by:tanmh
ID: 1453137
hi,
thanks for the answer. it works!!!
just for clarification, why can't i set the window state in the form properties?

andrea
0
 
LVL 1

Expert Comment

by:hddp666
ID: 1453138
It's anybody's guess why the shell function ignores the windowstate property that is set at design-time. Maybe VB6.0 will have this bug fixed.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question