Solved

Automatically making an excel sheet

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 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