Results 1 to 4 of 4
  1. #1
    quuxbazer is offline Novice
    Windows 7 Access 2007
    Join Date
    Oct 2010
    Posts
    2

    Controlling embedded excel files on Access Form

    Hi everyone,



    I have a bound object frame on my form which has contains an excel object (class = Excel.Sheet.8). When the user wants to create a new excel file, I have button such as:

    Code:
    Private Sub CreateNew_Click()
        On Error Resume Next
        If IsNull(Excel) Then
            Excel.Action = acOLECreateEmbed
            Excel.Action = acOLEActivate
        Else
            If MsgBox("It seems you already have data, would you still like to create a clean sheet?", vbYesNo, "Warning") = vbYes Then
                Excel.Action = acOLECreateEmbed
                Excel.Action = acOLEActivate
            End If
        End If
    End Sub
    Now my question is, how do I access the cells in the embedded Excel file? Like for example, I want to get the data like how I do this in excel: Worksheets(1).Cells(1,1)

    I looked at some other posts on how to do this. But if I dim a variable like: Dim a as Excel.Worksheet, Access gives me an error saying "User defined type not defined".

    Thanks ahead for the help guys! (I'm still kind of a noob with vba. Is there a good tutorial on learning about Objects and their manipulation?)

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    most likely, the user-defined error is coming from the broken link to the excel library. put a checkbox next to it in the 'references' menu item under the 'tools' menu.

    is that embedded sheet an active x object?

  3. #3
    quuxbazer is offline Novice
    Windows 7 Access 2007
    Join Date
    Oct 2010
    Posts
    2
    Thanks, now the excel reference is fixed.

    So I kinda figured out how to control the object:

    Excel.Action = acOLEActivate
    Dim test As Excel.Workbook
    Set test = Excel.Object
    MsgBox (test.Worksheets(1).Cells(1, 1))

    But apparently I HAVE to activate the object first. If I don't active the object, "Set test = Excel.Object" gives me an error saying the Excel.Object is NULL.

    Is there a way around this? Thanks.

    EDIT: Wait, nevermind, it only gave me that error when I put the event on the form.onload. Hmmm

    anyways, Thanks for your help ajetrumpet!

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    I'm not really sure either. You may want to check ms's kb for information on using them. sorry I couldn't help more!

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

Similar Threads

  1. Replies: 0
    Last Post: 07-13-2010, 07:45 AM
  2. Cannot import excel or text files
    By donald_s in forum Access
    Replies: 2
    Last Post: 04-13-2010, 11:48 PM
  3. Replies: 2
    Last Post: 02-19-2010, 08:05 PM
  4. Export Query to Various Excel Files
    By dalet in forum Import/Export Data
    Replies: 7
    Last Post: 11-09-2009, 09:22 AM
  5. Access Report and embedded images
    By joypanattil in forum Reports
    Replies: 0
    Last Post: 11-22-2008, 03:50 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