Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default how to call a function procedure

I have the following function procedu


Function read_only_status()
read_only_status = activeworkbook.ReadOnly
End Function


This returns a value of "true" when the workbook is read-only and "false"
when it is not. This works fine when the function is first entered into a
cell. However, since the function doesn't refer to a cell, if the workbook
status is changed (from/to read-only) the function is not called and the
value is not updated.

Any suggestions as to how I can get the function called when the read-write
status changes or some other work around?

Thank you.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default how to call a function procedure

Try putting

Application.Volatile True

as the first line in the function.



"nathan" wrote in message
...
I have the following function procedu


Function read_only_status()
read_only_status = activeworkbook.ReadOnly
End Function


This returns a value of "true" when the workbook is read-only
and "false"
when it is not. This works fine when the function is first
entered into a
cell. However, since the function doesn't refer to a cell, if
the workbook
status is changed (from/to read-only) the function is not
called and the
value is not updated.

Any suggestions as to how I can get the function called when
the read-write
status changes or some other work around?

Thank you.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default how to call a function procedure

Add the line Application.Volitile. This will force the formula to re-evaluate
each time the spreadhseet is calculated. As an aside you should always
specify the return value of a function in order to make it more efficient.

Function read_only_status() as Boolean
appliation.volitile
read_only_status = activeworkbook.ReadOnly
End Function

--
HTH...

Jim Thomlinson


"nathan" wrote:

I have the following function procedu


Function read_only_status()
read_only_status = activeworkbook.ReadOnly
End Function


This returns a value of "true" when the workbook is read-only and "false"
when it is not. This works fine when the function is first entered into a
cell. However, since the function doesn't refer to a cell, if the workbook
status is changed (from/to read-only) the function is not called and the
value is not updated.

Any suggestions as to how I can get the function called when the read-write
status changes or some other work around?

Thank you.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default how to call a function procedure

Use Chip's code. He seems a little better at spelling... Volatile
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Add the line Application.Volitile. This will force the formula to re-evaluate
each time the spreadhseet is calculated. As an aside you should always
specify the return value of a function in order to make it more efficient.

Function read_only_status() as Boolean
appliation.volitile
read_only_status = activeworkbook.ReadOnly
End Function

--
HTH...

Jim Thomlinson


"nathan" wrote:

I have the following function procedu


Function read_only_status()
read_only_status = activeworkbook.ReadOnly
End Function


This returns a value of "true" when the workbook is read-only and "false"
when it is not. This works fine when the function is first entered into a
cell. However, since the function doesn't refer to a cell, if the workbook
status is changed (from/to read-only) the function is not called and the
value is not updated.

Any suggestions as to how I can get the function called when the read-write
status changes or some other work around?

Thank you.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default how to call a function procedure

The "application.volatile" does the trick. However, I now have another
problem.

Basically, what I am trying to do is to set the worksheet background to a
particular .gif file when the workbook is changed to/from "read-only". Since
my workbook uses DDE links, it calculates continuously. Therefore, the
function is called continuously, slows the workbook down and makes the screen
flicker as it continuously sets the background picture.

I have separated this task into the following two functions to try to keep
the function that sets the background (function #2) to only run when the
read-only status (function #1) changes, but it still does it continuously:

#1
Function read_only_status() As Byte

Application.Volatile True
If ActiveWorkbook.ReadOnly = True Then
read_only_status = 1
End If
If ActiveWorkbook.ReadOnly = False Then
read_only_status = 2
End If

End Function

#2
Function set_background(status As Byte)

If status = 1 Then
Worksheets("a.book").SetBackgroundPicture "c:watermark.gif"
End If

If status = 2 Then
Worksheets("a.book").SetBackgroundPicture Delete
End If

End Function

Any suggestions??


"Jim Thomlinson" wrote:

Use Chip's code. He seems a little better at spelling... Volatile
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Add the line Application.Volitile. This will force the formula to re-evaluate
each time the spreadhseet is calculated. As an aside you should always
specify the return value of a function in order to make it more efficient.

Function read_only_status() as Boolean
appliation.volitile
read_only_status = activeworkbook.ReadOnly
End Function

--
HTH...

Jim Thomlinson


"nathan" wrote:

I have the following function procedu


Function read_only_status()
read_only_status = activeworkbook.ReadOnly
End Function


This returns a value of "true" when the workbook is read-only and "false"
when it is not. This works fine when the function is first entered into a
cell. However, since the function doesn't refer to a cell, if the workbook
status is changed (from/to read-only) the function is not called and the
value is not updated.

Any suggestions as to how I can get the function called when the read-write
status changes or some other work around?

Thank you.


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
Call Procedure Ronbo Excel Programming 4 February 23rd 05 08:11 PM
Where else to look for procedure call Lulu Excel Programming 0 November 24th 04 03:07 PM
Where else to look for procedure call Lulu Excel Programming 2 November 24th 04 02:14 AM
call procedure bob Excel Programming 1 August 9th 03 12:40 AM
procedure won't call John Gittins Excel Programming 0 August 5th 03 08:17 PM


All times are GMT +1. The time now is 03:12 AM.

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

About Us

"It's about Microsoft Excel"