in reply to Sending excel file as an attachment

Any chance you forgot to close the file first? Happened a few times to various people ...

Jenda
Enoch was right!
Enjoy the last years of Rome.

  • Comment on Re: Sending excel file as an attachment

Replies are listed 'Best First'.
Re^2: Sending excel file as an attachment
by MoFiddy (Sexton) on Apr 12, 2011 at 19:41 UTC
    That was it! I closed the logfile and input file, but not the workbook.

    Thanks Jenda.

Re^2: Sending excel file as an attachment
by CountZero (Bishop) on Apr 13, 2011 at 08:31 UTC
    That still begs the question "Why did the attach method not return an error"?

    I had a quick look at the source-code of this method. It calls the build method but that method does not check if the file exists or is accessible. So there is no error checking done here and the usual "or die ..." invocation gives a false sense of security.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      It would return an error if the file did not exist at all, but it can hardly know you have it opened somewhere and that there are some data waiting to be written in some buffers or something. Or even that some object holds data that it will write into that file once you tell it to or destroy the object.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.