Solved

Automatically making an excel sheet

Posted on 2006-10-25
4
141 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

744 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

11 Experts available now in Live!

Get 1:1 Help Now