Results 1 to 3 of 3
  1. #1
    pk2317 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    9

    Using attached document as source for Bound Object Frame

    A related question to my earlier one:



    Is it possible to use a Bound Object Frame to display a Word document (or other OLE Object) that has been attached to a table? Here's the website I got my code from:

    http://blogs.msdn.com/b/access/archive/2007/08/30/using-vba-code-to-open-a-file-stored-in-the-new-access-2007-attachment-field.aspx

    I modified the code some, shown below. I have the public function first, and then the test function that is called when a command button is clicked. At this time I'm just using a small table (tblFiles) with an attachment field (Fil_File) that containts a single Word document attachment. I want it to display in the field [OLEBound7] on the form [frmDisplay].

    Code:
    Public Function OpenFirstAttachment(ByRef rstCurrent As DAO.Recordset, ByVal strFieldName As String) As DAO.Field
     
        Dim rstChild As DAO.Recordset2
        Dim fldAttach As DAO.Field2
        Dim strFilePath As String
     
        Set rstChild = rstCurrent.Fields(strFieldName).Value ' the .Value for a complex field returns the underlying recordset.
     
        Set fldAttach = rstChild.Fields("FileData") ' The binary data of the file.
     
        Set OpenFirstAttachment = fldAttach
     
        rstChild.Close ' cleanup
     
    End Function 'OpenFirstAttachment
    Code:
    Public Function TestFirst()
     
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
        Dim fldTemp As DAO.Field
     
        Const strTable = "tblFiles"         ' Table that contains attachment field
        Const strField = "Fil_File"         ' Attachment field in Table1
     
        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset(strTable)
     
        'rst.MoveNext                       ' Uncomment this line to go to the 2nd row in the Table.
     
        Set fldTemp = OpenFirstAttachment(rst, strField)
     
        Forms![frmDisplay]![OLEBound7].ControlSource = fldTemp
     
        rst.Close
        Set dbs = Nothing
        Set rst = Nothing
     
    End Function

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    pk,

    I just read the first few lines of your post, so I thought I would ask if you've checked out the active x controls? in 07, there is one to view xls files. have you tried that? I don't know if there is one for WORD, but it would make sense if there was.

    too much of this is going to get you confused: http://www.access-programmers.co.uk/...d.php?t=200301

  3. #3
    pk2317 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    9
    If you're referring to the "Microsoft Office Spreadsheet 11.0" control listed in the ActiveX controls list, when I select it from the list and click OK, I get a messagebox telling me "Microsoft Office Access does not support this ActiveX control." If there is a different ActiveX control that does work for Excel spreadsheets, I'd be more than happy to find out about it, because if it would help I can probably get the users to give me an Excel file with the information instead of a Word document.

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

Similar Threads

  1. Passing a Picture frame as a parameter
    By SacredFootballLB in forum Forms
    Replies: 1
    Last Post: 09-30-2010, 11:40 AM
  2. Replies: 1
    Last Post: 08-05-2010, 12:11 PM
  3. Replies: 0
    Last Post: 06-14-2010, 07:19 AM
  4. Replies: 2
    Last Post: 07-30-2009, 08:02 AM
  5. Replies: 1
    Last Post: 07-09-2006, 09:23 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