Results 1 to 5 of 5
  1. #1
    zippy483 is offline Novice
    Windows 7 Access 2003
    Join Date
    Feb 2010
    Posts
    26

    Killing open applications using VBA

    Hi all



    I am using the following code on closing a form in access to kill excell

    Set oWS = Nothing
    If Not oWB Is Nothing Then oWB.Close
    Set oWB = Nothing
    oExcel.Quit
    Set oExcel = Nothing

    all is fine and dandy and it does as i want it to do with the exception that on exiting I get a message box asking if I would like to save the changes to the excel file that is about to close.

    I haven't made any changes and wouldn't be doing so, so the question is how do I inhibit the save changes message box so that I never see it, using access vba, a modification to the above code would be nice

    Many thanks for your help

    Zippy483

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I have made the following assumptions in my code:

    • The excel file is located oin your hard drive.
    • The excel file is open.

    I have use a command button on its onClick event i have used the following code:

    Private Sub Command8_Click()
    Dim appExcel As Object
    Set appExcel = GetObject("C:\FILE1.xls")

    appExcel.Application.DisplayAlerts = False
    'appExcel.Application.Save
    appExcel.Application.DisplayAlerts = True
    appExcel.Application.Quit

    Set appExcel = Nothing

    End Sub


    This code is an extract of a larger code that I use to open and write on an existing excel file and then save it without prompt.
    If this solves your problem please mark this thread to be solved.

  3. #3
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I am jus curious have been able to solve your problem. If yes an in a different way please mark this thread solved and post your solution.

  4. #4
    zippy483 is offline Novice
    Windows 7 Access 2003
    Join Date
    Feb 2010
    Posts
    26
    Hi all and thanks for the help the code below has solved my problem merely by the addition of one line of code

    Cleanup: 'Closes Excel Worksheets and Workbooks
    oExcel.Application.DisplayAlerts = False
    Set oWS = Nothing
    If Not oWB Is Nothing Then oWB.Close
    Set oWB = Nothing
    oExcel.Quit
    Set oExcel = Nothing

    Many thanks once again

    Zippy483

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I am glad could help you.

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

Similar Threads

  1. Replies: 2
    Last Post: 02-26-2010, 08:14 AM
  2. too many forms open
    By Jaad in forum Database Design
    Replies: 0
    Last Post: 02-22-2010, 08:39 AM
  3. Replies: 0
    Last Post: 11-14-2009, 07:37 AM
  4. Front ends apps in split applications
    By Coolpapabell in forum Access
    Replies: 4
    Last Post: 10-14-2009, 01:51 AM
  5. Replies: 1
    Last Post: 06-04-2009, 07:43 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