View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
kope@dont_use.invalid kope@dont_use.invalid is offline
external usenet poster
 
Posts: 6
Default My own text using right click "New note"

Hi,

I want my own special text (3 lines) inserted in comment box when I right
click "New note"
In Office 2007 I could do that with the vba shown below, but it does not
work in Office 365.
Does someone have a solution that works with Office 365.
I am aware that it is possible to create a complete new button to the right
click menu, but I want to use the existing "New note"

I am running Windows 10 and Office 365

Kind regards,
Kaj Pedersen

This used to work in Office 2007

Insert in Module1
=================

Sub ThisIsMyOwnNote()

Dim cmt As Comment

Set cmt = ActiveCell.Comment

If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment
cmt.Text Text:="This is my own note"
Else
cmt.Text Text:=cmt.Text & Chr(10)
End If
End Sub

----------------------------------------------------------------------------------
Insert in This workbook
=======================

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Cell").Controls("Insert comment").Reset
End Sub

Private Sub Workbook_Open()
With Application.CommandBars("Cell").Controls("Insert comment")
.OnAction = "Testfile.xlsm" & "!ThisIsMyOwnNote"
End With
End Sub