Lin Kejian

Hi

How to set range/namedRange object Read-only in VSTO 2005/ Excel




Re: Team Foundation Server - Work Item Tracking How to set range/namedRange object Read-only in VSTO 2005/ Excel

Cindy Meister

Look at the Locked property of the Range object, the Protect method, as well as the Protection object (as applied to the worksheet and workbook objects).

In the Excel UI (Tools menu), if you want to protect parts of the workbook, you select ranges and objects the user is allowed to change and mark them to not be locked. When protection is activated, everything that hasn't been explicitly unlocked is locked.






Re: Team Foundation Server - Work Item Tracking How to set range/namedRange object Read-only in VSTO 2005/ Excel

Linkejian

Hi Cindy

your suggestion is not work

See the code

Code Snippet

Excel.Range rng1 = Globals.Sheet1.Range["a5","b8"] as Excel.Range;
rng1.Select();
rng1.Merge(false);
rng1.Locked = true;

whatever the rng1.Locked = true or false ,In the runtime ,the range can Modify by user in excel UI




Re: Team Foundation Server - Work Item Tracking How to set range/namedRange object Read-only in VSTO 2005/ Excel

Cindy Meister

Do some testing first in the UI, to learn how it works.

To repeat in another way: You have to set ranges to Locked = False, then protect the worksheet. The Locked settings won't take effect until protection has been activated.






Re: Team Foundation Server - Work Item Tracking How to set range/namedRange object Read-only in VSTO 2005/ Excel

Linkejian

Hi Cindy

When I use Excel to connect Team Fouondation Server and get a workitem list form Server , some cells is readonly and whole document can modify,When click the cells readonly , Excel UI auto move the active cell to next . this is what I want .

Can you Help me

.






Re: Team Foundation Server - Work Item Tracking How to set range/namedRange object Read-only in VSTO 2005/ Excel

Cindy Meister

Linkejian wrote:

Hi Cindy

When I use Excel to connect Team Fouondation Server and get a workitem list form Server , some cells is readonly and whole document can modify,When click the cells readonly , Excel UI auto move the active cell to next . this is what I want .

Can you Help me

No, I have no idea what you're talking about. But this is apparently not VSTO. Team Foundation Server (with Office integration) is supported in a different forum. http://forums.microsoft.com/MSDN/ShowForum.aspx ForumID=479&SiteID=1

I'll move this message thread for you, but it's rather long. So it's possible the folks there may not read through and answer. You may need to start over, there.






Re: Team Foundation Server - Work Item Tracking How to set range/namedRange object Read-only in VSTO 2005/ Excel

Swamy Subramanian

With TFS, we us Excel ListObject and not VSTO range/nameRange.

Also with TFS we mimic the read-only behavior using Excel Validation object. It is not true read-only as users can still type in these cells and when they exit the cell then Excel validation will kick in and display appropriate error message.

Look at Validation object in Excel VBA help for more details on how to use the validation objects