ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   On Error Resume Next (https://www.excelbanter.com/excel-programming/324391-error-resume-next.html)

Mike Archer[_2_]

On Error Resume Next
 
I want to switch backgrounds as an indication to the user
of unsaved changes. I want it to skip it if it is going
to cause a run time error so I use "on error resume next",
but it still errors when there is not enough memory. How
do I make it really skip the setbackgroundpicture function
if there is not enough memory?

On Error Resume Next
ThisWorkbook.Worksheets("Data").SetBackgroundPictu re
ThisWorkbook.Path & _
Application.PathSeparator & "QPIBackground.jpg"

TIA
Mike

AA2e72E

On Error Resume Next
 
Application.MemoryFree returns the number of bytes available to Excel to use.
You need to determine how many bytes are required for your operation and
compare this to what is available and the abandon or execute your operation.

"Mike Archer" wrote:

I want to switch backgrounds as an indication to the user
of unsaved changes. I want it to skip it if it is going
to cause a run time error so I use "on error resume next",
but it still errors when there is not enough memory. How
do I make it really skip the setbackgroundpicture function
if there is not enough memory?

On Error Resume Next
ThisWorkbook.Worksheets("Data").SetBackgroundPictu re
ThisWorkbook.Path & _
Application.PathSeparator & "QPIBackground.jpg"

TIA
Mike


Mike Archer[_3_]

On Error Resume Next
 
That sounds good. How do I determine how many bytes are
required for the operation?
Mike

-----Original Message-----
Application.MemoryFree returns the number of bytes

available to Excel to use.
You need to determine how many bytes are required for

your operation and
compare this to what is available and the abandon or

execute your operation.

"Mike Archer" wrote:

I want to switch backgrounds as an indication to the

user
of unsaved changes. I want it to skip it if it is

going
to cause a run time error so I use "on error resume

next",
but it still errors when there is not enough memory.

How
do I make it really skip the setbackgroundpicture

function
if there is not enough memory?

On Error Resume Next
ThisWorkbook.Worksheets("Data").SetBackgroundPictu re
ThisWorkbook.Path & _
Application.PathSeparator & "QPIBackground.jpg"

TIA
Mike

.


AA2e72E

On Error Resume Next
 
I am not sure I know the answer or how it coould be determined. I would guess
as follows:

When the operation fails, Ctrl + Break and then query available memory. Now
you know how much is NOT enough. Let this be A. I would add something to
this, say 8K, and assume that the operation is not possible unless A bytes +
8K is available.

You'll need to fine tune this with trial and error.


"Mike Archer" wrote:

That sounds good. How do I determine how many bytes are
required for the operation?
Mike

-----Original Message-----
Application.MemoryFree returns the number of bytes

available to Excel to use.
You need to determine how many bytes are required for

your operation and
compare this to what is available and the abandon or

execute your operation.

"Mike Archer" wrote:

I want to switch backgrounds as an indication to the

user
of unsaved changes. I want it to skip it if it is

going
to cause a run time error so I use "on error resume

next",
but it still errors when there is not enough memory.

How
do I make it really skip the setbackgroundpicture

function
if there is not enough memory?

On Error Resume Next
ThisWorkbook.Worksheets("Data").SetBackgroundPictu re
ThisWorkbook.Path & _
Application.PathSeparator & "QPIBackground.jpg"

TIA
Mike

.




All times are GMT +1. The time now is 03:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com