Results 1 to 5 of 5
  1. #1
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79

    Automation with Excel

    Hi,



    I am not sure if this is the right forum to ask this question. I hope someone recognise the issue.

    I am making my reports (quite complicated for Access) in Excel. I invoke Excel from VBA Access. My issue is that on some (not all) computers I get error on line "Set gappExcel = New Excel.Application"

    Prerequisites:
    - Reference to Excel "Microsoft Excel 16.0 Object Library"
    - Everyone has Excel 2016 & Acess 2016 where tested. (If different versions it might be a Early/Late binding issue. But everyone has the same version. For info I have used Early Binding)

    My code:
    Code:
    Public gappExcel As Excel.Application
    
    Sub OpenExcelApplication()
    
        'On some computer there is Run-Time 13 here
        Set gappExcel = New Excel.Application
    
    End Sub
    Anyone having an idea what to do?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What makes the reports so complicated cannot be done in Access?

    What is the exact error message?

    Do you need to just open the Excel file or will your Access VBA need to manipulate the file?

    Try: Set gappExcel = CreateObject("Excel.Application")

    Review: https://www.accessforums.net/showthread.php?t=65761
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Hi,

    I have attached a report as an example why I do the reports in Excel. I haven't found a way to do them in Access. All data is stored in tables in Access.

    Error message: Run-time error 13, "Type Mismatch"

    On my computer I never get the error message. It's about 50% of other computers. It has been working on some other before and now it doesn't. Not changed any Office version.

    If I use "Set gappExcel = CreateObject("Excel.Application")" I get the same error as "Set gappExcel = New Excel.Application" on other computers where nothing works. On my computer both works.
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Well, can't begin to guess why some comps have that issue and others don't. Doesn't seem to be anything terribly unusual about the sheet and no VBA code. How are you controlling cell colors? Don't see conditional formatting so this is manual? Don't even see any formulas in cells.

    Think I can see why Excel may be the better tool. However, you might find this thread interesting https://www.accessforums.net/showthread.php?t=18459. Unfortunately, some of the referenced threads no longer exist but the databases are still attached.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Joakim N is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    Oct 2016
    Posts
    79
    Hi,

    I found a way to solve this. However, I have no idea why it works now. It seems It cleaned up something. I just:
    1. Exported all modules
    2. Removed all moules in Db
    3. Imported all modules back

    Then it worked. The code is not changed a bit.

    Answer to June7: Yes, the color of cells are made by VBA code. No conditional formatting.

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

Similar Threads

  1. Access to Excel database reports automation
    By pzerarka in forum Database Design
    Replies: 3
    Last Post: 10-01-2015, 01:05 PM
  2. Problems with Range when using Excel Automation
    By offie in forum Programming
    Replies: 2
    Last Post: 08-13-2013, 07:51 AM
  3. Excel automation (open minimized)
    By jfgrenier in forum Programming
    Replies: 2
    Last Post: 11-06-2011, 05:53 AM
  4. Excel Automation Select Range Only with Data
    By orcinus in forum Programming
    Replies: 3
    Last Post: 02-09-2011, 01:03 PM
  5. Exporting to Excel with Automation using QueryDef
    By Niezels in forum Import/Export Data
    Replies: 3
    Last Post: 09-26-2010, 05:55 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