LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default free text box on a protected sheet

Hi Paul
Please ignore my previous e-mail as I have managed to get the code to run by
deleting some spaces. This is great, but I must ask you a further favour.
Can you tell me whether it is possible to run some code that will delete the
message that is created by your original code as I do not want the message to
remain indefinately on the sheet. Also is it possible to change the colour
of the message background and text colour.

Sorry for being a pain.

Thanks for your help
Regards
John

"Paul B" wrote:

John, if you select edit objects when you protect the sheet you will be able
to put in comments, or maybe use a macro like this

Sub AddComment()
'This code inserts a comment and allows you to enter the multi-lined text
'like using a typewriter.
' Enter one line at a time and it's resized at the end automatically
'By: Andrew Engwirda
'From http://blog.livedoor.jp/andrewe/ July 27,2005
'Code added to unprotect and protect the sheet
On Error Resume Next
Dim cmtMsg As String, nwLne As String, LneCnt As Long, shCmt As Long

Const Password As String = "123" '*********Change Password
Here************

If TypeName(Selection) < "Range" Then Exit Sub
ActiveSheet.Unprotect Password:=Password
AddLine:
nwLne = InputBox("Text Line: " & LneCnt + 1 & vbNewLine & vbNewLine & _
"New Text Lines are added automatically." & vbNewLine & _
"Leave blank or push ""Cancel"" to exit.", "Please write
your comment")
If LneCnt 0 Then cmtMsg = cmtMsg & Chr(10) & nwLne Else cmtMsg = nwLne
LneCnt = LneCnt + 1
If nwLne < "" Then GoTo AddLine
cmtMsg = Left(cmtMsg, Len(cmtMsg) - 1)
Application.ScreenUpdating = False
With ActiveCell
.ClearComments
.AddComment
With .Comment
.Visible = True
.Shape.AutoShapeType = msoShapeRoundedRectangle
.Shape.Shadow.Visible = msoFalse
.Shape.Select True
.Text Text:=cmtMsg
If cmtMsg < "" Then .Shape.TextFrame.AutoSize = True
shCmt = MsgBox("Do you want the comment to remain visible? ", _
vbYesNo, "Keep comment visible?")
If shCmt = vbNo Then .Visible = False
End With
.Select
End With
ActiveSheet.Protect Password:=Password
Application.ScreenUpdating = True
End Sub




--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"John Davies" wrote in message
...
I have a protected spreadsheet that occasionaly I need to add comments or
notes to. However all cells on the sheet are in use. Is it possible to

have
a command button that if it is clicked will bring up a resizeable box that
text can be entered into? If so please advise on the code needed.

Thanks in advance for any help.

Regards
John




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find text in free-format text field Eric_NY Excel Discussion (Misc queries) 5 May 27th 09 07:31 PM
Automate text import wizard in a protected sheet SNM Excel Discussion (Misc queries) 1 February 7th 08 02:58 PM
How do I make a text box accessible in a protected Excel sheet? JWarnick-SHH Excel Worksheet Functions 5 March 16th 06 01:53 PM
TEXT TO COLUMNS PROTECTED SHEET Jeracho Excel Discussion (Misc queries) 1 August 26th 05 09:40 PM
Problem pasting a row from a hidden sheet to the first free row on another visible sheet Didier Poskin Excel Programming 2 January 10th 04 01:18 AM


All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"