Results 1 to 4 of 4
  1. #1
    Steven.Allman is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Feb 2010
    Posts
    118

    PDF Attachments Opening in Browser or Adobe App

    Access data is stored on a Sharepoint list.
    I have two forms, as generic as possible trying to solve this issue.
    If I "create form" and just have Title and Attachments, it will default open attachments in the browser.
    If I " form design", select the list, drag my attachment field over and title field, attachments open in Adobe.


    What the holy heck.
    I WANT the documents to open in Adobe. i checked every setting on these forms and cannot figure out what the difference is.

    Is there some wierd code somewhere, I can input that forces Access to open the documents in desktop app?
    O365 if anyone is wondering.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    paste this code into a module


    then give it the path to open,
    whatever path is in the textbox will open in its native application


    OpenNativeApp txtBox


    Store the path to the file in the field, and it will open ANY file in its native application.


    Code:
    
    #If Win64 Then      'Public Dclare PtrSafe Function
      Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
      Private Declare PtrSafe Function GetDesktopWindow Lib "user32" () As Long
    #else
      Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
      Private Declare Function GetDesktopWindow Lib "user32" () As Long
    #End If
    
    
    
    
    Const SW_SHOWNORMAL = 1
    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_ACCESSDENIED = 5&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_ASSOCINCOMPLETE = 27&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&
    
    
    
    
    Public Sub OpenNativeApp(ByVal psDocName As String)
    Dim r As Long, msg As String
    
    
    r = StartDoc(psDocName)
    If r <= 32 Then
        'There was an error
        Select Case r
            Case SE_ERR_FNF
                msg = "File not found"
            Case SE_ERR_PNF
                msg = "Path not found"
            Case SE_ERR_ACCESSDENIED
                msg = "Access denied"
            Case SE_ERR_OOM
                msg = "Out of memory"
            Case SE_ERR_DLLNOTFOUND
                msg = "DLL not found"
            Case SE_ERR_SHARE
                msg = "A sharing violation occurred"
            Case SE_ERR_ASSOCINCOMPLETE
                msg = "Incomplete or invalid file association"
            Case SE_ERR_DDETIMEOUT
                msg = "DDE Time out"
            Case SE_ERR_DDEFAIL
                msg = "DDE transaction failed"
            Case SE_ERR_DDEBUSY
                msg = "DDE busy"
            Case SE_ERR_NOASSOC
                msg = "No association for file extension"
            Case ERROR_BAD_FORMAT
                msg = "Invalid EXE file or error in EXE image"
            Case Else
                msg = "Unknown error"
        End Select
    '    MsgBox msg
    End If
    End Sub
    
    
    
    
    Private Function StartDoc(psDocName As String) As Long
    Dim Scr_hDC As Long
    
    
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
    End Function

  3. #3
    Steven.Allman is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Feb 2010
    Posts
    118
    i appreciate the assist, but it seems this is a workaround for something that is already there, somewhere.
    IE: Depending on how I create the form, it defaults to browser OR defaults to application.
    Any ideas?
    And each list item has its own attachments, so the file path would be dependent on the list item, right? I couldnt set the file path in that way.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    export to c:\temp,
    then open

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 10-15-2021, 08:41 AM
  2. Replies: 2
    Last Post: 06-19-2019, 09:43 AM
  3. Replies: 2
    Last Post: 04-12-2017, 08:43 AM
  4. Replies: 8
    Last Post: 11-06-2012, 03:41 PM
  5. Opening URL Without Opening Browser
    By steve2507 in forum Access
    Replies: 0
    Last Post: 02-26-2012, 06:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums