PC Review


Reply
Thread Tools Rate Thread

Detect if workbook is readonly

 
 
=?Utf-8?B?RHVuY2Fu?=
Guest
Posts: n/a
 
      13th Jul 2007
Hi

I was wondering if there were a simple way to detect if the workbook, when
opened, was opened in read-only mode? The reason for this is that I have
code in place to automatically time-out the book after 5 minutes of
inactivity, but I wouldn't want this to happen if it were opened as
read-only. I would just need to suppress the code in the workbook_open
handler (or insert an if statement to determine if it should be run).

Any help gratefuly received!

Duncan
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      13th Jul 2007
You can check with something like:

If ThisWorkbook.ReadOnly = True Then
or
If Activeworkbook.ReadOnly = True Then

Depending on where the code is.

Duncan wrote:
>
> Hi
>
> I was wondering if there were a simple way to detect if the workbook, when
> opened, was opened in read-only mode? The reason for this is that I have
> code in place to automatically time-out the book after 5 minutes of
> inactivity, but I wouldn't want this to happen if it were opened as
> read-only. I would just need to suppress the code in the workbook_open
> handler (or insert an if statement to determine if it should be run).
>
> Any help gratefuly received!
>
> Duncan


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      13th Jul 2007
Duncan,

This macro could go in the workbook open event to determione if it is read
only:-

Sub stantiate()
If ActiveWorkbook.ReadOnly Then
MsgBox "Read-only" '<Don't time out
Else
MsgBox "Read & Write" '<Timeout
End If
End Sub

Mike

"Duncan" wrote:

> Hi
>
> I was wondering if there were a simple way to detect if the workbook, when
> opened, was opened in read-only mode? The reason for this is that I have
> code in place to automatically time-out the book after 5 minutes of
> inactivity, but I wouldn't want this to happen if it were opened as
> read-only. I would just need to suppress the code in the workbook_open
> handler (or insert an if statement to determine if it should be run).
>
> Any help gratefuly received!
>
> Duncan

 
Reply With Quote
 
=?Utf-8?B?RHVuY2Fu?=
Guest
Posts: n/a
 
      13th Jul 2007
Thanks guys - i knew it'd be something simple!

Cheers

Duncan

"Mike H" wrote:

> Duncan,
>
> This macro could go in the workbook open event to determione if it is read
> only:-
>
> Sub stantiate()
> If ActiveWorkbook.ReadOnly Then
> MsgBox "Read-only" '<Don't time out
> Else
> MsgBox "Read & Write" '<Timeout
> End If
> End Sub
>
> Mike
>
> "Duncan" wrote:
>
> > Hi
> >
> > I was wondering if there were a simple way to detect if the workbook, when
> > opened, was opened in read-only mode? The reason for this is that I have
> > code in place to automatically time-out the book after 5 minutes of
> > inactivity, but I wouldn't want this to happen if it were opened as
> > read-only. I would just need to suppress the code in the workbook_open
> > handler (or insert an if statement to determine if it should be run).
> >
> > Any help gratefuly received!
> >
> > Duncan

 
Reply With Quote
 
Dean Barkenhagen
Guest
Posts: n/a
 
      13th Jan 2010
OK, Does anyone know how to make this work in Excel 2007 when opening files from SharePoint? I get false in response to either (active or this) regardless of the status of the file.

This worked just fine when opening from the same library with Excel 2003, so I could error trap to save the file and clear the read-only status. Excel 2007 doesn't trigger the trap!!



Dunca wrote:

RE: Detect if workbook is readonly
13-Jul-07

Thanks guys - i knew it'd be something simple!

Cheers

Duncan

"Mike H" wrote:

Previous Posts In This Thread:

On Friday, July 13, 2007 6:50 AM
Dunca wrote:

Detect if workbook is readonly
Hi

I was wondering if there were a simple way to detect if the workbook, when
opened, was opened in read-only mode? The reason for this is that I have
code in place to automatically time-out the book after 5 minutes of
inactivity, but I wouldn't want this to happen if it were opened as
read-only. I would just need to suppress the code in the workbook_open
handler (or insert an if statement to determine if it should be run).

Any help gratefuly received!

Duncan

On Friday, July 13, 2007 7:15 AM
Dave Peterson wrote:

Re: Detect if workbook is readonly
You can check with something like:

If ThisWorkbook.ReadOnly = True Then
or
If Activeworkbook.ReadOnly = True Then

Depending on where the code is.

Duncan wrote:

--

Dave Peterson

On Friday, July 13, 2007 7:18 AM
Mike wrote:

Duncan,This macro could go in the workbook open event to determione if it is
Duncan,

This macro could go in the workbook open event to determione if it is read
only:-

Sub stantiate()
If ActiveWorkbook.ReadOnly Then
MsgBox "Read-only" '<Don't time out
Else
MsgBox "Read & Write" '<Timeout
End If
End Sub

Mike

"Duncan" wrote:

On Friday, July 13, 2007 8:00 AM
Dunca wrote:

RE: Detect if workbook is readonly
Thanks guys - i knew it'd be something simple!

Cheers

Duncan

"Mike H" wrote:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Javascript Martin Fractals with IE and VML
http://www.eggheadcafe.com/tutorials...in-fracta.aspx
 
Reply With Quote
 
Dean Barkenhagen
Guest
Posts: n/a
 
      13th Jan 2010
OK, Does anyone know how to make this work in Excel 2007
when opening files from SharePoint? I get false in
response to either (active or this) regardless of the
status of the file.

This worked just fine when opening from the same library
with Excel 2003, so I could error trap to save the file
and clear the read-only status. Excel 2007 doesn't
trigger the trap!!




Dunca wrote:

RE: Detect if workbook is readonly
13-Jul-07

Thanks guys - i knew it'd be something simple

Cheer

Dunca

"Mike H" wrote:

Previous Posts In This Thread:

On Friday, July 13, 2007 6:50 AM
Dunca wrote:

Detect if workbook is readonly
H

I was wondering if there were a simple way to detect if the workbook, when
opened, was opened in read-only mode? The reason for this is that I have
code in place to automatically time-out the book after 5 minutes of
inactivity, but I wouldn't want this to happen if it were opened as
read-only. I would just need to suppress the code in the workbook_open
handler (or insert an if statement to determine if it should be run)

Any help gratefuly received

Duncan

On Friday, July 13, 2007 7:15 AM
Dave Peterson wrote:

Re: Detect if workbook is readonly
You can check with something like

If ThisWorkbook.ReadOnly = True The
o
If Activeworkbook.ReadOnly = True The

Depending on where the code is

Duncan wrote

-

Dave Peterson

On Friday, July 13, 2007 7:18 AM
Mike wrote:

Duncan,This macro could go in the workbook open event to determione if it is
Duncan

This macro could go in the workbook open event to determione if it is read
only:

Sub stantiate(
If ActiveWorkbook.ReadOnly The
MsgBox "Read-only" '<Don't time ou
Els
MsgBox "Read & Write" '<Timeou
End I
End Su

Mik

"Duncan" wrote:

On Friday, July 13, 2007 8:00 AM
Dunca wrote:

RE: Detect if workbook is readonly
Thanks guys - i knew it'd be something simple

Cheer

Dunca

"Mike H" wrote:

On Wednesday, January 13, 2010 8:26 AM
Dean Barkenhagen wrote:

This doesn't work in 2007!
OK, Does anyone know how to make this work in Excel 2007 when opening files from SharePoint? I get false in response to either (active or this) regardless of the status of the file.

This worked just fine when opening from the same library with Excel 2003, so I could error trap to save the file and clear the read-only status. Excel 2007 doesn't trigger the trap!!


Submitted via EggHeadCafe - Software Developer Portal of Choice
Document Compatibility in Internet Explorer 8
http://www.eggheadcafe.com/tutorials...bility-in.aspx
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make Workbook ReadOnly Alan Microsoft Excel Programming 2 26th Apr 2007 11:18 AM
Detect readonly database =?Utf-8?B?Q2hhcmxlcyBUYW0=?= Microsoft Access Form Coding 1 17th Mar 2005 05:05 AM
Re: readonly attrib on a open workbook Bob Phillips Microsoft Excel Programming 0 27th Jul 2004 10:28 PM
How to hide a workbook and to detect a hidden workbook in visual basic jn1971 Microsoft Excel Programming 0 5th May 2004 10:08 PM
Workbook will not open as readonly Quoc Nguyen Microsoft Excel Crashes 3 22nd Aug 2003 10:11 PM


Features
 

Advertising
 

Newsgroups
 


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