Use file-status in IF ... THEN

  • Thread starter Thread starter Jan V.
  • Start date Start date
J

Jan V.

I have an Excel-file on a p2p network.
It has a password so that most network-users can open it for reading and
only some are able to change it (after they have entered the password).

*** I would like to make certain buttons available only when opened by the
latter and not available when opened "read-only". ***
Any ideas are welcome!

The password is added the "normal" way (Save As + Extra and enter the
password), so it is not programmed in some VBA routine or so (don't even
know if this can be done and this isn't my question either).

Jan V.
 
Assume you have 3 buttons placed on the worksheet "Sheet1"
The names of the 3 buttons are: "Button 1", "Button 2", "Button 3

Place the following macro into the "Thisworkbook" of the Excel file
If the file is opened as read only, the buttons will not be displayed; vice versa

'-----------------------------------------------------------------
Private Sub Workbook_Open(
Dim tmp As Boolea
tmp = Not ThisWorkbook.ReadOnl
With ThisWorkbook.Worksheets("Sheet1"
.DrawingObjects(Array("Button 1", "Button 2", "Button 3")).Visible = tm
End Wit
End Su
'-----------------------------------------------------------------

Regards
Edwin Ta
(e-mail address removed)
http://www.vonixx.co


----- Jan V. wrote: ----

I have an Excel-file on a p2p network
It has a password so that most network-users can open it for reading an
only some are able to change it (after they have entered the password)

*** I would like to make certain buttons available only when opened by th
latter and not available when opened "read-only". **
Any ideas are welcome

The password is added the "normal" way (Save As + Extra and enter th
password), so it is not programmed in some VBA routine or so (don't eve
know if this can be done and this isn't my question either)

Jan V
 
Jan,

Workbooks have a ReadOn ly property that you can test

If ActiveWorkbook.ReadOnly Then
ActiveWorkbook.SaveAs fileName:="NEWFILE.XLS"
End If-- HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top