Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Automatically making an excel sheet

Posted on 2006-10-25
4
Medium Priority
?
149 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 93

Accepted Solution

by:
Patrick Matthews earned 2000 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 93

Expert Comment

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

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

916 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