Hello All,

I am working on an Access 2010 application.
I would like to click on a command button and open a Adobe PDF document.
The code for the On-Click event is:

Set shell = CreateObject("WScript.Shell")
shell.Run """C:\Program Files (x86)\Adobe\Reader 11.0\Reader\acrord32.exe"" SourceFile"

When the Shell.Run line executes, Acrobat returns an error saying Access Denied.
I have RW access to the folder and can double-click on any PDF file there and open it successfully.

Can anyone explain why I can't open it from within my application?

Thanks in advance,
Rich

Dani AI

Generated

A few focused diagnostics and safer alternatives that commonly resolve an “Access Denied” when launching a PDF from Access.

Common culprits (short): incorrect command-line quoting or concatenation; launching across different privilege/UAC integrity levels; Adobe Reader “Protected Mode” / enhanced security or AV/group‑policy blocking programmatic launches; or the PDF living in a protected location (Program Files, a restricted share). As suggested, moving the PDF to a simple writable folder (for example C:\Temp) is a fast way to narrow the cause.

Safer, simpler ways to open the file (avoid hard‑coding Acrobat’s exe):

' Use the system default PDF handler (no Acrobat path required)
Application.FollowHyperlink "C:\Temp\example.pdf"

If a more explicit shell call is wanted, ShellExecute is robust (works with file associations and avoids DDE/instance-reuse quirks):

#If VBA7 Then
  Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _
     ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
#Else
  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
#End If

Sub OpenPDF(pdfPath As String)
  ShellExecute 0, "open", pdfPath, vbNullString, vbNullString, vbNormalFocus
End Sub

Quick troubleshooting checklist (actionable, no guessing): confirm whether Access is running elevated (or Acrobat is) and match their privilege level; test with the PDF on a local non-protected folder (as said); try Application.FollowHyperlink or ShellExecute to avoid hard-coded exe paths; check Adobe’s Protected Mode only as a temporary test (do not leave it disabled); review Event Viewer / AV logs for blocked launches. If opening via the system association works but calling Acrobat directly fails, prefer the association-based approach for reliability.

Maybe you need admin permissions to do that. Move the pdf file somewhere else such as c:\temp and see if the problem goes away.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.