Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88087

How to Insert Note using SendKeys?

$
0
0

I have Microsoft Office 365 2019.

I asked a question with an answer about "Insert Note" with .Fill.UserPicture.

I still have some error.

See Screencast.

I found the problem and it is SendKeys "+{F2}" (after inserting note it's open Note).

Sub Special_Note2_FillPicture(control As IRibbonControl)

    Dim img As FileDialog
    Dim i_add As String

    Set img = Application.FileDialog(msoFileDialogFilePicker)
        img.AllowMultiSelect = False
        img.Title = "Select the Image!"
        img.Show

    If img.SelectedItems.Count < 1 Then        
        MsgBox "No Image Selected"        
    Exit Sub

    Else            
        i_add = img.SelectedItems(1)
    End If


    Dim myComm As Comment
      If Not ActiveCell.Comment Is Nothing Then
        If MsgBox("The cell already contains a note, delete?", 4) - 7 Then
          ActiveCell.Comment.Delete
        Else: Exit Sub
        End If
      End If

    Set myComm = ActiveCell.AddComment
        With myComm.Shape
          .Height = 110
          .Width = 200
          .AutoShapeType = 1             'form
'          .Fill.UserTextured
          .Fill.UserPicture i_add
          .Line.ForeColor.RGB = RGB(255, 0, 0)
          .DrawingObject.Font.Name = "Consolas"
          .DrawingObject.Font.FontStyle = "normal"
          .DrawingObject.Font.Size = 8
        End With
          'emulate the choice of "Change note"
           SendKeys "+{F2}"
End Sub

Viewing all articles
Browse latest Browse all 88087

Trending Articles