Results 1 to 4 of 4
  1. #1
    smbrush is offline Experienced Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Posts
    30

    Show Word doc embedded in a table on a form with a bound object frame


    I'm trying to show a Word doc created in an OLE Object type field in a table. It has one record. My form has a bound object frame. The control source of the frame has been set to the table and field of OLE Object type holding my Word doc. There is no actual file on my hard drive or network.

    The frame doesn't show the Word doc in the field when the form is run in Form view. It is empty.

    How do I get the doc in the field of my table to appear in the frame on my form? What other property or coding must I add to show the doc?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    i find it better NOT to embed the word docs into the db. Instead, save the docs to a folder,
    put the file path in the table. This keeps the size of the db low.
    The code below allows users to open the document from access.

    paste this code into a module. (Alt-F11, insert , module)
    Then it will open ANY file via its extension....
    .pdf files will open in acrobat,
    .doc files in word
    etc

    USAGE:
    OpenNativeApp "c:\folder\file.xls"
    'opens in excel
    or
    OpenNativeApp field
    'opens item in field in native app

    Code:
    Option Compare Database
    Option Explicit
    
    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
    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
    smbrush is offline Experienced Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Posts
    30
    Thank you for your code but it doesn't answer my question. You're using an ocean to put out a match, so to speak. I'd like to know how to use the bound object frame to display a Word doc embedded in a field of a table. I'm not worried about file size since the doc has only one page. Setting the controlsource property of the frame isn't enough to display the doc. My question is, what other properties need to be set or what code needs to added to the form to display the doc?

    Does anyone know the answers to my questions? Please respond if you do but don't if you don't.

  4. #4
    smbrush is offline Experienced Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2018
    Posts
    30
    I'm marking this thread as solved even though it isn't. It seems no one knows how to work with these object frame controls. Access SUCKS!!!!!

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

Similar Threads

  1. Replies: 6
    Last Post: 10-11-2015, 03:47 PM
  2. Bound Object Frame
    By bigguy in forum Forms
    Replies: 4
    Last Post: 04-15-2015, 03:14 PM
  3. Bound Object Frame Combo sorted Results
    By kevsim in forum Programming
    Replies: 7
    Last Post: 01-08-2011, 06:30 PM
  4. Replies: 2
    Last Post: 10-18-2010, 07:53 AM
  5. Replies: 1
    Last Post: 08-05-2010, 12:11 PM

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