Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
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
Excel:VB properties window will not open; project explorer is ok DJ Excel Programming 0 December 2nd 08 04:33 PM
Open MS Project From Excel & read Task Properties List MVP Wannabe[_2_] Excel Programming 6 November 21st 07 02:27 PM
Open workbook properties on save. Colinhp Excel Programming 1 July 7th 06 04:54 PM
Properties transferring from excel cells to word file properties lubo Excel Programming 4 July 12th 05 11:24 AM
Controlling EXCEL on open properties wtpcomplab Excel Programming 1 February 18th 05 03:25 AM


All times are GMT +1. The time now is 10:54 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"