Solved

Automatically making an excel sheet

Posted on 2006-10-25
4
142 Views
Last Modified: 2010-04-30
I've got everything else down, i just need to stop the user from selecting certain cells (without hiding them).  In excel this is done by going through the menus like so:
Tools -> Protection -> Protect Sheet ...

The menu comes up and then you can select from the list with the label
Allow all users of this worksheet to:
|_| Select Locked Cells
|_| Select unlocked Cells

allong with others
By default, the user is allowed to select any cells even though they are protected.  I need to make it in my generated xls file that the user cannot select the locked cells.  How is this done?

As a note, I'm using vb6 with the office11 excel library.  Thanks.
-Chris
0
Comment
Question by:lillockey
  • 2
4 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 17806884
Use the Macro recorder in Excel and then look at the code it generates.

Leon
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 17811290
Assuming you have a variable, ws, of type Worksheet:

With ws
    .Protect Password:="pw", DrawingObjects:=True, Contents:=True, Scenarios:=True
    .EnableSelection = xlUnlockedCells
End With

Patrick
0
 

Author Comment

by:lillockey
ID: 17812843
THANK YOU :).  That was EXACTLY what I was looking for.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 17813006
You're welcome :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA loop through headers using value 3 57
DIR issue 7 51
VBA/SQL - Connect to SQL server and pull data 4 88
Prevent checkbox click event occur while editing it in vb6 8 34
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now