PC Review


Reply
Thread Tools Rate Thread

Allowing Chart creation in protected worksheets sheets using VB co

 
 
=?Utf-8?B?QW50aG9ueSBIYXJkaW5n?=
Guest
Posts: n/a
 
      9th May 2007
I'm currently struggling with a spreadsheet that generates a table of output
data in a worksheet using VB in Excel 2003. I want to prevent the user from
editing the data created, but still allow the user to create a chart from
that data in the worksheet. I don't want to create the chart in advance, as
the size of the table is not fixed.

I've found that using the Potect Worksheet command from the excel menus
allows me to password protect the sheet, and allow the editing of objects.
Once protected, the worksheet allows the creation, editing and deletion of
charts. This is great: exactly what I'm looking for.

My problems begin when I re-run the function that crates the output data.
To access the worksheet I'm using the VB protect method with
UserInterfaceOnly:=True. However, this seems to overwrite the protection
settings, no longer allowing chart creation/deletion.

Online help for the Protect method suggests that it is only possible to
permit editing of drawing objects, not all objects like you can from the
Excel menus. Is this the case? If so, does anyone know of any way round
this?

Many thanks for your time.

Anthony.
 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      9th May 2007
Anthony,
This works for me in XL2002:

Sub Macro1()

Range("D6").Select
'Protect
ActiveSheet.Protect DrawingObjects:=False, Contents:=True,
Scenarios:=True, UserInterfaceOnly:=True
'Unlocked cell
Range("E7").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("D5:E12")
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ActiveSheet.Shapes("Chart 4").IncrementLeft 353.25
ActiveSheet.Shapes("Chart 4").IncrementTop 103.5

'This is a locked cell
Range("A1").Value = "Done"
End Sub

NickHK

"Anthony Harding" <(E-Mail Removed)> wrote in
message news:928A641F-58A8-458D-9BCB-(E-Mail Removed)...
> I'm currently struggling with a spreadsheet that generates a table of

output
> data in a worksheet using VB in Excel 2003. I want to prevent the user

from
> editing the data created, but still allow the user to create a chart from
> that data in the worksheet. I don't want to create the chart in advance,

as
> the size of the table is not fixed.
>
> I've found that using the Potect Worksheet command from the excel menus
> allows me to password protect the sheet, and allow the editing of objects.
> Once protected, the worksheet allows the creation, editing and deletion of
> charts. This is great: exactly what I'm looking for.
>
> My problems begin when I re-run the function that crates the output data.
> To access the worksheet I'm using the VB protect method with
> UserInterfaceOnly:=True. However, this seems to overwrite the protection
> settings, no longer allowing chart creation/deletion.
>
> Online help for the Protect method suggests that it is only possible to
> permit editing of drawing objects, not all objects like you can from the
> Excel menus. Is this the case? If so, does anyone know of any way round
> this?
>
> Many thanks for your time.
>
> Anthony.



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      9th May 2007
Note that the UserInterfaceOnly setting is lost on closing the file, so you
must restore it when the file is reopened.

Also, in a case like this, it may be just as easy to simply unprotect the
sheet, do the chart stuff, then reprotect the sheet.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"NickHK" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Anthony,
> This works for me in XL2002:
>
> Sub Macro1()
>
> Range("D6").Select
> 'Protect
> ActiveSheet.Protect DrawingObjects:=False, Contents:=True,
> Scenarios:=True, UserInterfaceOnly:=True
> 'Unlocked cell
> Range("E7").Select
> Charts.Add
> ActiveChart.ChartType = xlColumnClustered
> ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("D5:E12")
> ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
> ActiveSheet.Shapes("Chart 4").IncrementLeft 353.25
> ActiveSheet.Shapes("Chart 4").IncrementTop 103.5
>
> 'This is a locked cell
> Range("A1").Value = "Done"
> End Sub
>
> NickHK
>
> "Anthony Harding" <(E-Mail Removed)> wrote in
> message news:928A641F-58A8-458D-9BCB-(E-Mail Removed)...
>> I'm currently struggling with a spreadsheet that generates a table of

> output
>> data in a worksheet using VB in Excel 2003. I want to prevent the user

> from
>> editing the data created, but still allow the user to create a chart from
>> that data in the worksheet. I don't want to create the chart in advance,

> as
>> the size of the table is not fixed.
>>
>> I've found that using the Potect Worksheet command from the excel menus
>> allows me to password protect the sheet, and allow the editing of
>> objects.
>> Once protected, the worksheet allows the creation, editing and deletion
>> of
>> charts. This is great: exactly what I'm looking for.
>>
>> My problems begin when I re-run the function that crates the output data.
>> To access the worksheet I'm using the VB protect method with
>> UserInterfaceOnly:=True. However, this seems to overwrite the protection
>> settings, no longer allowing chart creation/deletion.
>>
>> Online help for the Protect method suggests that it is only possible to
>> permit editing of drawing objects, not all objects like you can from the
>> Excel menus. Is this the case? If so, does anyone know of any way round
>> this?
>>
>> Many thanks for your time.
>>
>> Anthony.

>
>



 
Reply With Quote
 
=?Utf-8?B?QW50aG9ueSBIYXJkaW5n?=
Guest
Posts: n/a
 
      9th May 2007
Thanks for your replies.

This does work for me, but I was actually hoping to allow other users to
create charts using the chartwizard on the userinterface, without having to
allow them to unprotect the sheet.

Perhaps it would be easier for me to ask for the chart inputs and then write
a routine to create the required chart?

Anthony.

"Jon Peltier" wrote:

> Note that the UserInterfaceOnly setting is lost on closing the file, so you
> must restore it when the file is reopened.
>
> Also, in a case like this, it may be just as easy to simply unprotect the
> sheet, do the chart stuff, then reprotect the sheet.
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> http://PeltierTech.com
> _______
>
>
> "NickHK" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Anthony,
> > This works for me in XL2002:
> >
> > Sub Macro1()
> >
> > Range("D6").Select
> > 'Protect
> > ActiveSheet.Protect DrawingObjects:=False, Contents:=True,
> > Scenarios:=True, UserInterfaceOnly:=True
> > 'Unlocked cell
> > Range("E7").Select
> > Charts.Add
> > ActiveChart.ChartType = xlColumnClustered
> > ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("D5:E12")
> > ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
> > ActiveSheet.Shapes("Chart 4").IncrementLeft 353.25
> > ActiveSheet.Shapes("Chart 4").IncrementTop 103.5
> >
> > 'This is a locked cell
> > Range("A1").Value = "Done"
> > End Sub
> >
> > NickHK
> >
> > "Anthony Harding" <(E-Mail Removed)> wrote in
> > message news:928A641F-58A8-458D-9BCB-(E-Mail Removed)...
> >> I'm currently struggling with a spreadsheet that generates a table of

> > output
> >> data in a worksheet using VB in Excel 2003. I want to prevent the user

> > from
> >> editing the data created, but still allow the user to create a chart from
> >> that data in the worksheet. I don't want to create the chart in advance,

> > as
> >> the size of the table is not fixed.
> >>
> >> I've found that using the Potect Worksheet command from the excel menus
> >> allows me to password protect the sheet, and allow the editing of
> >> objects.
> >> Once protected, the worksheet allows the creation, editing and deletion
> >> of
> >> charts. This is great: exactly what I'm looking for.
> >>
> >> My problems begin when I re-run the function that crates the output data.
> >> To access the worksheet I'm using the VB protect method with
> >> UserInterfaceOnly:=True. However, this seems to overwrite the protection
> >> settings, no longer allowing chart creation/deletion.
> >>
> >> Online help for the Protect method suggests that it is only possible to
> >> permit editing of drawing objects, not all objects like you can from the
> >> Excel menus. Is this the case? If so, does anyone know of any way round
> >> this?
> >>
> >> Many thanks for your time.
> >>
> >> Anthony.

> >
> >

>
>
>

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      9th May 2007
That's what I do.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Anthony Harding" <(E-Mail Removed)> wrote in
message news:8313BD90-9B1B-48BF-A575-(E-Mail Removed)...
> Thanks for your replies.
>
> This does work for me, but I was actually hoping to allow other users to
> create charts using the chartwizard on the userinterface, without having
> to
> allow them to unprotect the sheet.
>
> Perhaps it would be easier for me to ask for the chart inputs and then
> write
> a routine to create the required chart?
>
> Anthony.
>
> "Jon Peltier" wrote:
>
>> Note that the UserInterfaceOnly setting is lost on closing the file, so
>> you
>> must restore it when the file is reopened.
>>
>> Also, in a case like this, it may be just as easy to simply unprotect the
>> sheet, do the chart stuff, then reprotect the sheet.
>>
>> - Jon
>> -------
>> Jon Peltier, Microsoft Excel MVP
>> Tutorials and Custom Solutions
>> http://PeltierTech.com
>> _______
>>
>>
>> "NickHK" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Anthony,
>> > This works for me in XL2002:
>> >
>> > Sub Macro1()
>> >
>> > Range("D6").Select
>> > 'Protect
>> > ActiveSheet.Protect DrawingObjects:=False, Contents:=True,
>> > Scenarios:=True, UserInterfaceOnly:=True
>> > 'Unlocked cell
>> > Range("E7").Select
>> > Charts.Add
>> > ActiveChart.ChartType = xlColumnClustered
>> > ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("D5:E12")
>> > ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
>> > ActiveSheet.Shapes("Chart 4").IncrementLeft 353.25
>> > ActiveSheet.Shapes("Chart 4").IncrementTop 103.5
>> >
>> > 'This is a locked cell
>> > Range("A1").Value = "Done"
>> > End Sub
>> >
>> > NickHK
>> >
>> > "Anthony Harding" <(E-Mail Removed)> wrote in
>> > message news:928A641F-58A8-458D-9BCB-(E-Mail Removed)...
>> >> I'm currently struggling with a spreadsheet that generates a table of
>> > output
>> >> data in a worksheet using VB in Excel 2003. I want to prevent the
>> >> user
>> > from
>> >> editing the data created, but still allow the user to create a chart
>> >> from
>> >> that data in the worksheet. I don't want to create the chart in
>> >> advance,
>> > as
>> >> the size of the table is not fixed.
>> >>
>> >> I've found that using the Potect Worksheet command from the excel
>> >> menus
>> >> allows me to password protect the sheet, and allow the editing of
>> >> objects.
>> >> Once protected, the worksheet allows the creation, editing and
>> >> deletion
>> >> of
>> >> charts. This is great: exactly what I'm looking for.
>> >>
>> >> My problems begin when I re-run the function that crates the output
>> >> data.
>> >> To access the worksheet I'm using the VB protect method with
>> >> UserInterfaceOnly:=True. However, this seems to overwrite the
>> >> protection
>> >> settings, no longer allowing chart creation/deletion.
>> >>
>> >> Online help for the Protect method suggests that it is only possible
>> >> to
>> >> permit editing of drawing objects, not all objects like you can from
>> >> the
>> >> Excel menus. Is this the case? If so, does anyone know of any way
>> >> round
>> >> this?
>> >>
>> >> Many thanks for your time.
>> >>
>> >> Anthony.
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re : Excel HyperLinks to WorkSheets & Chart-Sheets tkt_tang@hotmail.com Microsoft Excel Programming 4 21st Nov 2008 01:35 AM
Allowing users to run macros on protected worksheets =?Utf-8?B?U0RVTkZPUkQ=?= Microsoft Excel Programming 3 30th Jan 2007 08:56 PM
Allowing users to add comments to cells on protected sheets scottchampion@gmail.com Microsoft Excel Discussion 0 15th Nov 2006 12:05 AM
Allowing data entry in protected sheets =?Utf-8?B?RGF2aWQ=?= Microsoft Excel Misc 1 7th Nov 2006 09:18 PM
Allowing spell check on protected worksheets =?Utf-8?B?QWxsb3dpbmcgc3BlbGwgY2hlY2sgb24gcHJvdGVj Microsoft Excel Setup 1 8th Feb 2005 07:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:15 AM.