如何使用SendKeys插入注释? [英] How to Insert Note using SendKeys?
本文介绍了如何使用SendKeys插入注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有Microsoft Office 3652019.
I have Microsoft Office 365 2019.
I asked a question with an answer about "Insert Note" with .Fill.UserPicture
.
我仍然有一些错误.
请参见截屏.
我发现了问题,它是 SendKeys"+ {F2}"
(在插入便笺后,它是打开的便笺).
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
推荐答案
0我找到解决方案的键.我重新编写了一下代码:
Sub Note_FiilPictureDialog(control As IRibbonControl)
Dim img As FileDialog
Dim i_add As String
Dim myComm As Comment
Set img = Application.FileDialog(msoFileDialogFilePicker)
img.AllowMultiSelect = False
img.Title = "Select the Image!"
img.Show
If img.SelectedItems.Count < 1 Then
Exit Sub
Else
i_add = img.SelectedItems(1)
End If
'If the cell contains a `Note` delete!
If Not ActiveCell.Comment Is Nothing Then
ActiveCell.Comment.Delete
End If
On Error GoTo nexterr
ActiveCell.ClearComments
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
'emulate the choice of "Change note".
SendKeys "+{F2}"
Exit Sub
nexterr:
MsgBox "You can only select images!", vbCritical, "Error"
ActiveCell.ClearComments
End With
End Sub
这篇关于如何使用SendKeys插入注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文