excel - 我希望将存储在剪贴板中的图像放置到 excel 电子表格上的特定位置
问题描述
我使用 Microsoft 项目作为图像的来源,并希望粘贴到 Excel 工作簿中指定工作表上的特定位置。
Sub CreateImageAndPaste()
Dim EStart As String, LFin As String
EStart = ActiveProject.StatusDate - 30
LFin = Tsk.Finish + 30
'Create View, filter and table in MS Project and apply
Application.PaneClose
MSProject.CalculateAll
Application.EditCopyPicture Object:=False, ForPrinter:=0, SelectedRows:=0, FromDate:=EarliestStart, ToDate:=LFin, ScaleOption:=pjCopyPictureShowOptions, MaxImageHeight:=-1#, MaxImageWidth:=-1#, MeasurementUnits:=2
With xlsheet
.Activate
.Cells(1, 1) = t
DoEvents
.Paste
DoEvents
End With
此片段在复制/粘贴所需图像时非常有效。但是,图像会粘贴到活动工作表的单元格 A1 中。我希望左上角位于单元格 A3 中。如何才能做到这一点?我已经研究了网络,但找不到使用 EditCopy 的图像的示例,请提前致谢。
解决方案
请以这种方式尝试:
With xlsheet
.Activate
.Cells(1, 1) = t
.Paste
Application.Selection.ShapeRange.item(1).top = .Range("A3").top
Application.Selection.ShapeRange.item(1).left = .Range("A3").left
End With
推荐阅读
- javascript - npm - EPERM:不允许操作,在 Windows 上读取
- java - 在 Spring JPA 存储库的 findByTopN 中动态设置 N
- visual-studio - x86 汇编器 pushf 导致程序退出
- java - 如果我只是在 Kotlin 中编写,我是否需要为我的 Android Studio 升级到 Java 8?
- javascript - Socket.io, io.use 发生在连接之前?
- c# - JsonSerializer 不包含 Parse 的定义
- r - 将数据转换为长格式——观察之间插入的其他变量
- python - 子进程在python中完成执行后如何通知父进程
- r - 从 PDF 中抓取数据
- spring-boot - Spring Integration - 将事件延迟 45 分钟,然后调用方法