Results 1 to 5 of 5

Close active File and Active window

Threaded View

  1. #1
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,505

    Close active File and Active window

    Hi Guys...

    This is probably very basic but have not yet come across a solution...
    I always make use of this code for closing my designed excel applications, however this closes all excel files

    Private Sub CommandButton4_Click()
    Unload Me
    ThisWorkbook.Save
    Application.Quit
    Application.ActiveWindow.Close savechanges:=False
    ActiveWorkbook.Close savechanges:=True
    End Sub
    This code leaves a grey window open...what code can i make use of to close my file and It's active window without closing all excel files?
    Private Sub CommandButton4_Click()
    Unload Me
    ThisWorkbook.Save
    Application.ActiveWindow.Close savechanges:=False
    ActiveWorkbook.Close savechanges:=True
    End Sub
    Last edited by Sintek; 01-14-2019 at 11:24 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Change VBA code for a specific window to any active window
    By dawondr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2016, 04:00 PM
  2. Switch from Active Window to Variable Window/Rename Varaible Sheet
    By CravingGod in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-04-2016, 09:52 AM
  3. Save file so that next time it's opened Range A1 is active and in the window?
    By dmasters4919 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-18-2015, 11:27 AM
  4. resize active window ie: add to the height of the active window
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-07-2014, 01:55 AM
  5. Replies: 1
    Last Post: 01-04-2014, 06:37 PM
  6. Close only active file and not all excel files
    By lfmemp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2012, 04:11 PM
  7. keystroke to close active workbook window
    By Vickie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-07-2005, 07:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1