+ Reply to Thread
Results 1 to 4 of 4

Beforeclose sub suddenly stopped working

  1. #1
    Registered User
    Join Date
    03-05-2006
    Posts
    28

    Beforeclose sub suddenly stopped working

    Hi

    I have this code
    Please Login or Register  to view this content.
    In the thisworkbook section of my workbook. Which has worked fine for months.
    When I click the x to close the workbook, it saves itself and does not ask me.

    Now I have added a section which incorporates a sendkeys command.
    Please Login or Register  to view this content.
    When the module with sendkeys in is run and I click the x to close the workbook, it asks me if I want to save the book.

    I cannot see what else it could be but is there any workaround this?
    Thanks

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Beforeclose sub suddenly stopped working

    What are you using Sendkeys for?

    There's no reason why the code shouldn't fire. Try popping some break points or MsgBox's in the code and you will be able to see if it's getting to the points that you are expecting it to.

    For info I'd scrap using the variable as there seems little point and you should turn screen updating back on if you switch it off but in this case I wouldn't bother.

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Beforeclose sub suddenly stopped working

    cuewoz;

    It depends on where the sendkeys is inserted in the code. I went round and round with a similar problem, until I realized that I had to put a "Stop" into my code.

    Sendkeys just puts keystrokes in the keyboard buffer. Your computer waits until something asks for them.
    Examples:
    If the Sendkeys is right before the msgbox, then your computer will send the keystrokes to the msgbox, The "FileName" portion of the keystrokes will be ignored by the msgbox, but then the "Enter" will click the "OK" button.
    If your code gets all the way through then your computer may be sending the keystrokes to the active cell in your spreadsheet (causing .Saved to be set to False), and triggering the question to Save.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  4. #4
    Registered User
    Join Date
    03-05-2006
    Posts
    28

    Re: Beforeclose sub suddenly stopped working

    Hi
    thanks for the replys
    I am using sendkeys to enter the save as dialog box, when I use cutepdf to turn the sheet automatically into a pdf file and saves it into another folder.
    I cannot put msgboxs in as it doesn't even run the code. as I put in a break in the code but as soon as I go to close the workbook, up pops do you want to save.

+ 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