+ Reply to Thread
Results 1 to 7 of 7

Saving clipboard when closing window

  1. #1
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58

    Saving clipboard when closing window

    I imagine this is probably a very obvious one, but I couldn't find the (correct) answer on Google.

    In my macro, I am closing a window. When just using the ActiveWorkbook.Close command, when I run the macro I am asked whether I would like to save the changes (no) and whether I want to save the data I have copied to the clipboard (yes).

    The first problem is solved easily by changing the command to ActiveWorkbook.Close savechanges:=False, but it still prompts me to ask if I want to save the data on the clipboard.

    Is there a line or string of text to add to that command to skip the prompting?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Application.DisplayAlerts = False

    Rgds

  3. #3
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58
    Does that command always assume the answer is 'Yes' instead of bringing up the question yes/no/cancel?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    The command doesn't assume anything. It's an instruction to the Application to suppress bringing up the query window in the first place.

    If earlier in your code you have set the DisplayAlerts to False, you can of course reset the alerts with Application.DisplayAlerts = True

    Regards

  5. #5
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58
    Aha,

    so if I place it before the command to close the workbook, it will ignore the question whether I want to clear the clipboard (and so will continue to remember what I copied), and when I then close the workbook and not save the changes, it forgets that I have set the preferences to not show pop-up questions.

    Genius. I am most grateful.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Since it's an Application level instruction I don't think you are correct to imply that just because you close the wb, the DisplayAlerts=False instruction is forgotten. It will remain until you change it to True or close and reopen the Excel application.

    If behind the question is the requirement to clear the clipboard, then the instruction Application.CutCopyMode = False will do it.

    Regards

  7. #7
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58
    Am glad you corrected me there. Have changed it back to True at the end of the macro to make sure it doesn't affect anything I do afterwards.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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