Link to home
Start Free TrialLog in
Avatar of Thomas
ThomasFlag for United States of America

asked on

How to open/run Windows Snipping Tool from Access vba?

I want to open/run the Windows 10 snipping tool from Access vba code. The code below produces the error "Windows cannot find 'C:\Windows\System32\SnippingTool.exe' ". Of course the exe file is in that location. Outside of Access, the snipping tool runs as expected. Any ideas? Thanks.

Private Sub cmdSnippingTool_Click()
    Dim strProgramPath As String
    Dim lngResult As EnumShellExecuteErrors
    Dim ShellExecute As New CShellExecute
   
    lngResult = seeNoError
    strProgramPath = "C:\Windows\System32\SnippingTool.exe"
    Set ShellExecute = New CShellExecute
    lngResult = ShellExecute.LaunchProgram(strProgramPath, , , sesSW_SHOWMAXIMIZED)
   
    If lngResult <> seeNoError Then
      MsgBox "Error on LaunchDocument: " & lngResult
    End If
    Set ShellExecute = Nothing
End Sub
ASKER CERTIFIED SOLUTION
Avatar of ☠ MASQ ☠
☠ MASQ ☠

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Thomas,

Change the full path to this:

C:\Windows\Sysnative\SnippingTool.exe

Btw, documented a couple of years ago in this EE thread:
https://www.experts-exchange.com/questions/29003803/Restore-Windows-7-Snipping-Tool-function-to-Windows-10.html

Regards, Joe
Avatar of Thomas

ASKER

Works perfectly. Thanks to both MASQ and Joe Winograd.
You're welcome, Thomas, very glad to hear that it works for you. Regards, Joe