且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过VB将图像添加到Excel注释

更新时间:2023-11-24 17:04:40



Re: 调整添加到评论的图像



添加到评论中时,我同意图像看起来很丑陋。

我发现必须确定图片的宽高比(AR)和评论相同AR的大小。



如果你有一个固定的图像库,我会确定每个的AR图像并将图片名称和AR保存在一个数组中,以便在您的代码中使用。

我使用固定高度进行注释,并根据商业广告"文件或文件夹"中的AR调整宽度。工作簿(3周试用)。

如果图片是疯狂的,那么在运行中,可以将图片添加到工作表,确定AR,删除图片然后创建评论。



这样的东西对你有用...

用objComment.Shape

  .LockAspectRatio = False

  .Height = ConstantNumber

  .Width = ConstantNumber * AR

  .LockAspectRatio = True

结束与
ObjComment.Shape.Fill ...
$
'---


Re:  Sizing images added to comments

Images can look pretty ugly, I agree, when added to a comment.
I found one has to determine the aspect ratio (AR) of the picture and size the comment to the same AR.

If you have a fixed library of images, I would determine the AR of each image and save the picture name and AR in an array for use in your code.
I use a fixed height for comments and adjust the width according to the AR in my commercial "Files or Folders" workbook (3 week trial).
If the pictures come out of the wild, then on the fly, one can add the picture to worksheet, determine the AR, delete the picture and then create the comment.

Something like this should work for you...
With objComment.Shape
  .LockAspectRatio = False
  .Height = ConstantNumber
  .Width = ConstantNumber * AR
  .LockAspectRatio = True
End With
ObjComment.Shape.Fill ...
'---
Jim Cone

美国俄勒冈州波特兰市
https://goo.gl/IUQUN2  (Dropbox)
Jim Cone
Portland, Oregon USA
https://goo.gl/IUQUN2 (Dropbox)