View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Simon Lloyd[_1295_] Simon Lloyd[_1295_] is offline
external usenet poster
 
Posts: 1
Default VBA in Excel Open properties


You can't as far as i know check if the password has been used to open
the workbook but you can check for read only like this:

Code:
--------------------
Private Sub Workbook_Open()
If (GetAttr(ThisWorkbook.Path & "\" & ThisWorkbook.Name) And vbReadOnly) Then
MsgBox "The Workbook is Read-Only!!", vbInformation
End If
End Sub
--------------------


*How to Save a Workbook Event Macro*
1. *Copy* the macro above placing the cursor to the left of the
code box hold the *CTRL & Left Click,* then *Right Click* selected code
and *Copy.*
2. Open your Workbook and *Right Click* on any *Worksheet's Name Tab*
3. *Left Click* on *View Code* in the pop up menu.
4. Press *ALT+F11* keys to open the *Visual Basic Editor.*
5. Press *CTRL+R* keys to shift the focus to the *Project Explorer
Window*
6. Press the *Down Arrow Key* until *ThisWorkbook* is highlighted in
blue.
7. *Press* the *Enter* key to move the cursor to the *Code Window*
8. *Paste* the macro code using *CTRL+V*
9. *Save* the macro in your Workbook using *CTRL+S*

mccann_mj;609975 Wrote:
I have an Excel 2007 file that when opened, asks for a password, but if
you
don't have the password, will open as a read only (using the "Save As",
tools, General Options). I have a userform that opens upon opening the
workbook. I'm trying to find a way that if the password is not used,
the form
does not open up; if the password is used, the form pops up. Is there
an open
property I can "read" to determine if the password was used?

--
Michael JM



--
Simon Lloyd

Regards,
Simon Lloyd
'Microsoft Office Help' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: 1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=169334

Microsoft Office Help