Results 1 to 2 of 2
  1. #1
    jzellman is offline Novice
    Windows 10 Access 2013
    Join Date
    Feb 2016
    Posts
    1

    ms access vba code to close specific excel workbook

    Kind of new to VBA in Access.



    I was able to export a table into excel however I need the original excel workbook closed before the export.

    Why wouldn't the following command work before the export:

    Workbook(filename).Close

    If not is there a subroutine I should create?


    Thanks

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    ActiveWorkbook.Close SaveChanges:=True

    should only close the active workbook, not any other workbooks.


    If the workbook that you want to close is not the active one, you can refer to it by name:

    Workbooks("OtherWorkbook.xlsm").Close SaveChanges:=True

    this answer is by: HansV
    www.eileenslounge.com

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

Similar Threads

  1. Add VBA code to an Exported Excel Workbook
    By gasmaskman in forum Programming
    Replies: 13
    Last Post: 02-11-2014, 10:00 AM
  2. Save and close Excel Workbook
    By scoe in forum Access
    Replies: 5
    Last Post: 07-30-2013, 08:50 AM
  3. Replies: 5
    Last Post: 07-22-2013, 01:11 PM
  4. Create Excel workbook from code
    By GraeagleBill in forum Programming
    Replies: 8
    Last Post: 12-08-2012, 01:58 PM
  5. Replies: 1
    Last Post: 11-21-2010, 10:26 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