Shell Function

rapsr59

Registered User.
Local time
Today, 15:31
Joined
Dec 5, 2007
Messages
93
Ok Ladies and Gentlemen

The Shell function opens an executable program using…

Private Function OpenPayroll()

‘Open the Payroll program
strAppName = "MSACCESS.exe"
strPath = "C:\My Files\Private\Payroll\"
strAppType = "mdb"
strFileName = "Payroll" & "." & strAppType
strConCan = strAppName & " " & Chr(34) & strPath & strFileName & Chr(34)
Call Shell(strConCan, 1) ‘Open Payroll

End Function


If you repeat the shell function, Windows opens a second copy of the application. Not Good!



In Access Visual Basic For Apps (VBA)
  • How do you check if a specific program is currently loaded?
  • How do you change focus from the MDB that has the focus to the MDB that is loaded (Payroll) and does not have the focus?
Example:

If PayrollLoaded Then ‘Function to return True if Application is loaded?
‘SetFocus on Loaded Program
Call SetFocusOnPayroll ‘What Code Goes Here?
Else
Call OpenPayroll ‘Call the OpenPayroll function
Call SetFocusOnPayroll
End If


Thanks a bunch,

Richard
 
With another Office applicaiton like this - Automation would be much more standard than Shelling it out.
You're then able to hook into running instances too - instead of just creating new ones all the time.

Are you familar with Automation code at all - or would a little bit by way of example help?
 

Users who are viewing this thread

Back
Top Bottom