+ Reply to Thread
Results 1 to 4 of 4

Possible bug?

  1. #1
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500

    Possible bug?

    Hi I got Excell 2000

    I have a piece of code which opens a workbook(a) and copys selected sheets to Workbook(B). I then close workbook (A) but do not want the "do you want to save..." display to pop up so I wrote the following code to stop it from displaying the save option.

    Application.DisplayAlerts = False
    ActiveWorkbook.Close
    Application.DisplayAlerts = True

    If i step through my code as soon as I get to the close bit and move my mouse over application.dis its telling me that it is true. which of coarse make the save option pop up. so I wrote this code in case I turned the displayalerts off some where else.

    If Application.DisplayAlerts = True Then Application.DisplayAlerts = False
    ActiveWorkbook.Close
    Application.DisplayAlerts = True

    when I step through it picks it up as being true and does the then bit and then carrys on as it still being true. it seems to be ignoring the fact that I had made it false.

    I know this works as I have other workbooks that do a similar thing.

    Any Ideas?

  2. #2
    Tom Ogilvy
    Guest

    Re: Possible bug?

    When you step through the code, each line of code is like a separate sub.
    So when you set it to false and stop, excel changes it back to true. This
    is not the behavior if you run it normally.

    A better way to avoid the original problem is

    ActiveWorkbook.Close SaveChanges:=False

    and avoid the DisplayAlerts
    --
    Regards,
    Tom Ogilvy


    "funkymonkUK" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Hi I got Excell 2000
    >
    > I have a piece of code which opens a workbook(a) and copys selected
    > sheets to Workbook(B). I then close workbook (A) but do not want the
    > "do you want to save..." display to pop up so I wrote the following
    > code to stop it from displaying the save option.
    >
    > Application.DisplayAlerts = False
    > ActiveWorkbook.Close
    > Application.DisplayAlerts = True
    >
    > If i step through my code as soon as I get to the close bit and move my
    > mouse over application.dis its telling me that it is true. which of
    > coarse make the save option pop up. so I wrote this code in case I
    > turned the displayalerts off some where else.
    >
    > If Application.DisplayAlerts = True Then Application.DisplayAlerts =
    > False
    > ActiveWorkbook.Close
    > Application.DisplayAlerts = True
    >
    > when I step through it picks it up as being true and does the then bit
    > and then carrys on as it still being true. it seems to be ignoring the
    > fact that I had made it false.
    >
    > I know this works as I have other workbooks that do a similar thing.
    >
    > Any Ideas?
    >
    >
    > --
    > funkymonkUK
    > ------------------------------------------------------------------------
    > funkymonkUK's Profile:

    http://www.excelforum.com/member.php...o&userid=18135
    > View this thread: http://www.excelforum.com/showthread...hreadid=517809
    >




  3. #3
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500
    still seems to be asking me to save as well as telling that there is large amount of data on the clip board. is there a way to stop that
    Last edited by funkymonkUK; 03-02-2006 at 04:51 AM.

  4. #4
    Tom Ogilvy
    Guest

    Re: Possible bug?

    If you copied a range doing

    application.CutCopyMode = False

    will empty the clipboard. Do this before the code that evokes the message

    Or you can do

    Application.DisplayAlerts = False
    ' code the evokes the message
    Application.Displayalerts = True

    --
    Regards,
    Tom Ogilvy


    "funkymonkUK" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > seems to be working except it keeps saying the is large amount of data
    > on the clip board. is there a way to stop that
    >
    >
    > --
    > funkymonkUK
    > ------------------------------------------------------------------------
    > funkymonkUK's Profile:

    http://www.excelforum.com/member.php...o&userid=18135
    > View this thread: http://www.excelforum.com/showthread...hreadid=517809
    >




+ 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