In Excel - Producing a Solid background and recognizing a CR

EE Pros,

I have some code that was written for me to bring up a notepad for me to input notes.  Here are my two asks;

1.) How do I put a solid white background on the Note section (it expands to cover the text entered)


2.) How do I get it recognize a Carriage Return?  Right now I have to hit Alt. Return to get it to do a normal Carriage Return.


option Explicit
Sub ShowTextBox()
Dim shp As Shape
Dim ws As Worksheet
Dim wn As Window
Dim sngHeight As Single, sngLeft As Single, sngTop As Single, sngWidth As Single

Set ws = ActiveSheet
On Error Resume Next
Set shp = ws.Shapes("Notes")
On Error GoTo 0
Set wn = Application.ActiveWindow
sngLeft = wn.Left + ws.Cells(wn.ScrollRow, wn.ScrollColumn).Left + wn.Width * 0.5
sngWidth = 10
sngTop = wn.Top + ws.Cells(wn.ScrollRow, wn.ScrollColumn).Top + wn.Height / 8
sngHeight = 800

ws.Protect Password:="PASSWORD", UserInterFaceOnly:=True, DrawingObjects:=False
'ActiveSheet.Unprotect Password:="PASSWORD"

If shp Is Nothing Then
    Set shp = ws.Shapes.AddTextbox( _
        Orientation:=msoTextOrientationHorizontal, Left:=sngLeft, Top:=sngTop, Width:=sngWidth, Height:=sngHeight)
    shp.Name = "Notes"
    shp.Top = sngTop
    shp.Left = sngLeft
    shp.Visible = msoTrue
End If

shp.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
'Selection.PrintObject = 0

'Selection.PrintObject = msoFalse

End Sub

Sub ResizeTextbox()
On Error Resume Next
ActiveSheet.Shapes("Notes").TextFrame2.AutoSize = msoAutoSizeShapeToFitText
On Error GoTo 0
End Sub

Sub HideTextBox()
On Error Resume Next
ActiveSheet.Shapes("Notes").Visible = msoFalse
ActiveSheet.Protect Password:="jam"
On Error GoTo 0
End Sub

Thank you in advance.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Excel amusantCommented:

I have amended your code to get the required output. please see attached example file.


you can change the shape interior color as follow.

ActiveSheet.Shapes("Notes").Interior.ColorIndex = 2  

the use Carriage Return you should use chr(10) or chr(13) as follow.

    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = "Text to write" & Chr(10) & "Text to write"


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bright01Author Commented:
Excel amusant,

Where do I put the;

ActiveSheet.Shapes("Notes").Interior.ColorIndex = 2  


Bright01Author Commented:
It works!  Great..... "much thanks".........

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.