How to use shellwait not minimize the calling VBA

Posted on 2016-11-11
Medium Priority
Last Modified: 2016-11-14
We have VBA that uses shellwait; It does it's function as supposes to, call the apps/wait/return control to the next line.  Howver, the shellwait when return control to the next line, it minimize the windows the shellwait was called.

We want not to minimize.

How can we do this?
Question by:rayluvs
  • 3
  • 2

Author Comment

ID: 41884344
Oops! Forgot to include the shellwait code we  use...

Declare Sub Sleep Lib "kernel32" (ByVal milliseconds As Long)

'Rutine para crear todo para usar SHELLWAIT
 Private Const NORMAL_PRIORITY_CLASS = &H20&
 Private Const INFINITE = -1&
 cb As Long
 lpReserved As String
 lpDesktop As String
 lpTitle As String
 dwX As Long
 dwY As Long
 dwXSize As Long
 dwYSize As Long
 dwXCountChars As Long
 dwYCountChars As Long
 dwFillAttribute As Long
 dwFlags As Long
 wShowWindow As Integer
 cbReserved2 As Integer
 lpReserved2 As Long
 hStdInput As Long
 hStdOutput As Long
 hStdError As Long
End Type

 hProcess As Long
 hThread As Long
 dwProcessID As Long
 dwThreadID As Long
End Type

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
 hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
 lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
 lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
 ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
 ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
 lpStartupInfo As STARTUPINFO, lpProcessInformation As _
Private Declare Function CloseHandle Lib "kernel32" (ByVal _
 hObject As Long) As Long
Public Sub ShellWait(Pathname As String, Optional WindowStyle As Long)
 Dim ret As Long
'Initialize the STARTUPINFO structure:
 With start
     .cb = Len(start)
     If Not IsMissing(WindowStyle) Then
         .dwFlags = STARTF_USESHOWWINDOW
         .wShowWindow = WindowStyle
     End If
 End With
'Start the shelled application:
 ret& = CreateProcessA(0&, Pathname, 0&, 0&, 1&, _
         NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
'Wait for the shelled application to finish:
 ret& = WaitForSingleObject(proc.hProcess, INFINITE)
 ret& = CloseHandle(proc.hProcess)
End Sub

Open in new window

LVL 24

Accepted Solution

crystal (strive4peace) - Microsoft MVP, Access earned 2000 total points
ID: 41884451
here is your declaration for ShellWait:
Public Sub ShellWait(Pathname As String, Optional WindowStyle As Long)

When you call ShellWait, you can send the window style you desire as an optional paramater.  Here is a Microsoft reference page with choices you can pick:


Assisted Solution

rayluvs earned 0 total points
ID: 41886332
Thanx!! Didn't quite understand. but found it: it's vbNormalNoFocus

So for any member that may come with problem and don't want to read, the line should read:

ShellWait (pathname-app-arguments), vbNormalNoFocus

Author Closing Comment

ID: 41886336
Chouse our entry as assisted so member don't have the info without reading up.
LVL 24
ID: 41886676
you're welcome ~ happy to help

actually, the close parenthesis goes AFTER all the arguments ;)
... IF you preface it with Call
If not, no parentheses are used around the arguments since this is a Sub, not a Function that returns a value that can be handled.

here is an example:

MsgBox "my message",, "my title"
Call MsgBox ("my message",, "my title")
If MsgBox ("my message", vbYesNo, "my title") = vbYes then

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

624 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