Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA in Excel Open properties
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA in Excel Open properties
Michael,
The .ReadOnly property should tell you if the file is in a ReadOnly state or not. So, your Workbook_Open event could look something like the following: Private Sub Workbook_Open() If ThisWorkbook.ReadOnly Then 'add code for the file being in a ReadOnly state End If End Sub Best, Matthew Herbert "mccann_mj" 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA in Excel Open properties
Thanks for the info. It worked as I wanted it! (kind of rare for this project)
-- Michael JM "Matthew Herbert" wrote: Michael, The .ReadOnly property should tell you if the file is in a ReadOnly state or not. So, your Workbook_Open event could look something like the following: Private Sub Workbook_Open() If ThisWorkbook.ReadOnly Then 'add code for the file being in a ReadOnly state End If End Sub Best, Matthew Herbert "mccann_mj" 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel:VB properties window will not open; project explorer is ok | Excel Programming | |||
Open MS Project From Excel & read Task Properties List | Excel Programming | |||
Open workbook properties on save. | Excel Programming | |||
Properties transferring from excel cells to word file properties | Excel Programming | |||
Controlling EXCEL on open properties | Excel Programming |