Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328

    Excel open/close with access 2016

    I have an access 2007 file (saved as Acess 2003) that exports/imports to/from an excel 2003 xls file successfully. My partner has access 2016. She uses my Access 2003 program, but her Access 2016 requires an excel xlsm file file to export/import. We must open-close after export so that the calculation results can be imported (A link just takes to long to send results back). The reason we have to use excel is too long to discuss here.




    The import/export action with the 2016 Access works, except for the fact that she has to open/close the excel file herself. The code just won't do it.
    :
    Here is my open close code (gotten from good people in this forum)
    First one:
    Dim xl As Excel.Application, wb As Excel.Workbook (works fine in access2003)

    Alternate when above didn't work (also gotten on this forum)
    Dim xl As Object
    Dim wb As Object
    then:
    Set xl = CreateObject("Excel.Application")
    Set wb = xl.Workbooks.Open(CurrentProject.Path & "" & .ExcelFile)
    wb.close True
    xl.Quit


    I have checked several sites and other parts of this forum, but no answer as to why Access 2016 doesn't open/close the xlsm file. There is another problem when using xlsm file with Access 2007, but will discuss some other time.


    Any help much appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    Apparently forum is dropping \ from between quote marks. What is .ExcelFile?
    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
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    The code is in a module. .excelfile refers to a form's text box that contains the name of the excel program. The \ somehow got lost on my paste . This code works fine in Access 2007 and 2003. The problem is making it work with 2016
    Last edited by gg80; 01-16-2019 at 05:09 PM.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    Using the . without prefix should error, unless you wrap code block in a With Me qualifier.

    Me.ExcelFile

    I use Access 2010 and no issue opening xls or xlsx or xlsm files. Would not expect 2016 to be any different.
    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
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    It isn't. Trying to troubleshoot a procedure with only a few lines certainly diminishes the chance of success. As for forum-messed up code, more than likely you can prevent such issues by using code tags. I'm surprised if no one has mentioned this to gg80 yet - aside from my signature.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    I do have a with statement. And, code works perfectly in Access 2007 and 2003. only fails with 2016.

  7. #7
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    I don't understand your reply. Especially "forum messed up code". All the code that I have gotten from help in the forum has been great! The "few lines" are all the lines for opening and closing the excel file. I also showed a variation.

    For some reason, the "" wasn't included in the paste or I somehow deleted it. I don't know about code tags-will research it. My main concern is that a procedure that works perfectly in Access 2007 fails in Access 2016

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    "forum-messed up code" refers to the forum dropping the \ character from your post.

    CODE tags generated by the # button above the post editor. Post your code between the tags.

    So far, we have no idea why 2016 fails with the procedure. Have you tried on another machine running 2016?
    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.

  9. #9
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Good idea-I will find another machine and try. I may also tell my partner to install 2007. As I understand it, you can have both on your machine at same time.

  10. #10
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Running 2 different versions requires certain conditions, and in some cases, is not possible. Better see
    https://support.office.com/en-us/art...7-b78c513788bf
    or similar.

    Would help if you could upload files for the db and workbook here, showing some dummy data if necessary. As I noted, 2016 will open xlsm, so it has to be something related to the files or the code (which we haven't seen all of) or a pc issue.

  11. #11
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    I have to get permission from the excel program designer. If he doesn't give it, I will create something with dummy data.. Appreciate your help much.

  12. #12
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Whatever you post make sure it exhibits the problem. I dont suspect the workbook as much as the db.

  13. #13
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    For some reason, not explained, Forum refuses to load the file. I will work on it some more

  14. #14
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    if files exceed the size limit you should see a warning. Usually zipping is necessary to get the size down. Maybe this will help
    https://www.accessforums.net/showthread.php?t=70301

  15. #15
    gg80 is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Posts
    328
    Thanks. In addition to zipping, I deleted all non-relevant tables, queries etc. Makes it work!

    Just to review. Works fine in Access 2003 & 2007 The open-close excel file code in a the module doesn't work with Access 2016 with this same excel file.

    I added some notes that will hopefully let you get to sources quicker. Let me know if want more.
    Attached Files Attached Files

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Compact and repair/ close access 2016
    By Simonhtc4 in forum Access
    Replies: 8
    Last Post: 04-20-2017, 11:15 AM
  2. Replies: 0
    Last Post: 01-05-2017, 11:47 AM
  3. Why does Excel close when I open Access.
    By Bmadigan2000 in forum Access
    Replies: 1
    Last Post: 12-23-2013, 11:11 AM
  4. Using Access to open and close Excel
    By murfeezlaw in forum Programming
    Replies: 4
    Last Post: 04-04-2012, 07:58 PM
  5. VBA to open excel, import on close of excel
    By bdaniel in forum Programming
    Replies: 0
    Last Post: 03-20-2010, 02:45 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