Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Code in ThisWorkbook crashes Excel

Excel 2002
WindowsXP

I have a macro in a module that works great when ran directly. But when I
run it from ThisWorkbook on a BeforeSave event it crashes Excel constantly.
Basically, the macro saves to an FTP site as well as the hard drive when the
user saves. I can have the user hit a macro button to run my
saveFTP/saveHardDrive macro directly and everything is great, but I'd like
to launch this action upon a normal save as well. But, like I said, calling
it up in BeforeSave crashes Excel.

I've had other projects become unstable when I called a macro from within
ThisWorkbook. So, I must be doing something consistently wrong. I shy away
from adding any code at all to ThisWorkbook because of my experiences. Maybe
I'm doing something wrong that can easily be corrected?

Does anyone have ideas or do I need to furnish the exact code?

Thanks,
Pat Beck





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Code in ThisWorkbook crashes Excel

Hi Pat

I thought I read in an earlier thread that if you use "DoEvents" it may
allow the system to complete all it's tasks before returning processing to
Excel. Perhaps you need the system to finish the save to your FTP site
before Excel starts it's save. Be sure to read the help file on "DoEvents"
before using it, it can yeild some unpredictable results.

Another thought is to try using "Application.Wait(Now + TimeValue("0:00:2"))
" for a few seconds at the end of the before save event, it may allow the
system to process unfinished tasks through multitasking. Using
Application.Wait has helped me quite a few times in the past.

I hope this helps,
Regards, Rocky McKinley

"Pat Beck" wrote in message
...
Excel 2002
WindowsXP

I have a macro in a module that works great when ran directly. But when I
run it from ThisWorkbook on a BeforeSave event it crashes Excel

constantly.
Basically, the macro saves to an FTP site as well as the hard drive when

the
user saves. I can have the user hit a macro button to run my
saveFTP/saveHardDrive macro directly and everything is great, but I'd like
to launch this action upon a normal save as well. But, like I said,

calling
it up in BeforeSave crashes Excel.

I've had other projects become unstable when I called a macro from within
ThisWorkbook. So, I must be doing something consistently wrong. I shy away
from adding any code at all to ThisWorkbook because of my experiences.

Maybe
I'm doing something wrong that can easily be corrected?

Does anyone have ideas or do I need to furnish the exact code?

Thanks,
Pat Beck







  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Code in ThisWorkbook crashes Excel

Hi, Rocky.

Actually, I'm pretty confident the system completes it save to the FTP site
before it starts its own save. In fact, I think it completes that and
completes my next procedure of saving it as the original file it was
(over-write) on my hard drive before it tries its own save. In between, it
writes info into cells and does that completely before it does its own save.
I saw this by creating breakpoints and checking the results.

I hope the answer is not DoEvents. <g I read the help file and it turned my
brain to spaghetti. I'll do without the Save event if that's what it takes.
<g I did try, however, your wait method. Unfortunately no joy. I set it for
10 seconds. It just took 10 seconds longer to crash. <g

I thought maybe it was the writing into the cells confusing Excel. Maybe
upon the Save launch it gets ready to save and then I change data in between
causing confusion when it finally does its save. But that's unlikely. I
commented out all writing lines of code and it still crashed when it started
its own save.

Thanks for the help and I'm all ears if you have other suggestions.

Pat

"Rocky McKinley" wrote in message
...
Hi Pat

I thought I read in an earlier thread that if you use "DoEvents" it may
allow the system to complete all it's tasks before returning processing to
Excel. Perhaps you need the system to finish the save to your FTP site
before Excel starts it's save. Be sure to read the help file on

"DoEvents"
before using it, it can yeild some unpredictable results.

Another thought is to try using "Application.Wait(Now +

TimeValue("0:00:2"))
" for a few seconds at the end of the before save event, it may allow the
system to process unfinished tasks through multitasking. Using
Application.Wait has helped me quite a few times in the past.

I hope this helps,
Regards, Rocky McKinley

"Pat Beck" wrote in message
...
Excel 2002
WindowsXP

I have a macro in a module that works great when ran directly. But when

I
run it from ThisWorkbook on a BeforeSave event it crashes Excel

constantly.
Basically, the macro saves to an FTP site as well as the hard drive when

the
user saves. I can have the user hit a macro button to run my
saveFTP/saveHardDrive macro directly and everything is great, but I'd

like
to launch this action upon a normal save as well. But, like I said,

calling
it up in BeforeSave crashes Excel.

I've had other projects become unstable when I called a macro from

within
ThisWorkbook. So, I must be doing something consistently wrong. I shy

away
from adding any code at all to ThisWorkbook because of my experiences.

Maybe
I'm doing something wrong that can easily be corrected?

Does anyone have ideas or do I need to furnish the exact code?

Thanks,
Pat Beck









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 View Code ThisWorkbook KC hotmail com> Excel Discussion (Misc queries) 2 February 24th 10 09:07 PM
Programatically adding macro to Excel - "ThisWorkbook" Aerojade Excel Discussion (Misc queries) 3 October 1st 08 12:53 PM
ThisWorkbook of personal.xls Jack Sons Excel Discussion (Misc queries) 4 August 29th 07 04:28 PM
Code crashes after clearing comments L. Howard Kittle Excel Worksheet Functions 2 February 20th 06 04:54 AM
ThisWorkbook Macros Random Excel Programming 1 August 16th 03 04:03 PM


All times are GMT +1. The time now is 01:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"