Mark01
asked on
Access 2010 Process.Start Error
I receive an "Object variable or With block variable not set" error when I try to run the following code in Access 2010:
Dim objProcess As Object
objProcess.Start ("C:\WINDOWS\system32\calc .exe")
However, the following code runs in VB.Net:
Dim StartCalc As Process = System.Diagnostics.Process .Start("C: \WINDOWS\s ystem32\ca lc.exe")
Please help resolve the error.
Dim objProcess As Object
objProcess.Start ("C:\WINDOWS\system32\calc
However, the following code runs in VB.Net:
Dim StartCalc As Process = System.Diagnostics.Process
Please help resolve the error.
I agree with John, Shell would be the approach I'd use to launch another application.
If you are trying to stick with you approach, how have you set your object variable exactly?
If you are trying to stick with you approach, how have you set your object variable exactly?
Dim objProcess As Object
Set objProcess = ???
objProcess.Start ("C:\WINDOWS\system32\calc.exe")
You can use an API call:
Option Compare Database
Option Explicit
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
Public Function OpenCalc()
ShellExecute 0, "open", "calc.exe", vbNullString, vbNullString, vbNormalFocus
End Function
But Shell seems much faster to open Calculator.
ASKER
Thank you for the code, John and Gustav. @Daniel Pineault: I don’t know how to set the object variable, which is why I asked the question. I searched the web and found several examples of how to use the Process object with VBA, but there were no process.start examples.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Daniel, Gustav and John. I will work with the code that you provided.
You are welcome!
Open in new window