Link to home
Start Free TrialLog in
Avatar of Bright01
Bright01Flag for United States of America

asked on

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)

and

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.

CODE:

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"
Else
    shp.Top = sngTop
    shp.Left = sngLeft
    shp.Visible = msoTrue
End If

shp.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
shp.Select
'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.

B.
ASKER CERTIFIED SOLUTION
Avatar of Excel amusant
Excel amusant

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bright01

ASKER

Excel amusant,

Where do I put the;

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

Code?

B.
It works!  Great..... "much thanks".........

B.