如何在VBA中将图片(图形对象)复制到剪贴板?
在 Excel 2003 中,我需要将 Graphics 对象 (sheet.PageSetup.LeftFooterPicture
) 复制到剪贴板。
我怎样才能做到这一点?
In Excel 2003, I need to copy a Graphics object (sheet.PageSetup.LeftFooterPicture
) to the Clipboard.
How can I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
像这样你可以将图片复制到剪贴板。
Like this you can copy pictures to the clipboard.
当我尝试复制似乎不想复制的内容时,我会从键盘打印屏幕,然后将其粘贴到 PAINT 附件。从那里,您可以裁剪掉任何不需要的内容,然后将新图像剪切并粘贴到新的 PAINT 文件中,使其干净。您可以将其保存为 .jpg 以便于使用。
希望有帮助。
When I try to copy something that doesn't seem to want to copy, I do a Print Screen from my keyboard and then paste it to the PAINT accessory. From there, you can crop out anything you don't want and then cut and paste the new image into a new PAINT file so it is clean. You can save it in a .jpg for easier use.
Hope that helps.
正如之前提到的,问题是我无法从图形对象中提取图片(LeftFooterPicture)
看了答案,我确实解决了这个问题。
所以这是我的解决方法:
我创建一个隐藏工作表并添加所有图片作为 Shape 对象(带有图片路径的 Shapes.AddPicture)
我将当前工作表名称和图片位置与形状绑定name
当我需要将图片复制到剪贴板时,我会在隐藏页面中查找图片(shape.CopyPicture xlScreen,xlPicture)
as it mentioned before the problem is that I cannot extract picture from graphic object(LeftFooterPicture)
Looking on the answers I did muddle through this issue.
so here is my workaround:
I create a hiden worksheet and add all pictures as Shape objects (Shapes.AddPicture with picture's path)
I bind a current workshhet name and picture position with shape name
By the time I need to copy a picture to cliapboard I look up the picture in the hiden page (shape.CopyPicture xlScreen, xlPicture)
根据 MSDN 一个
Graphic
通过文件(文件名)加载图像。文件名
应包含文件的完整路径,如“C:\myimage.jpg”,但保存工作表后,它将文件名更改为“myiamge”,不包含路径和扩展名。我无法在 Excel 中找到对该文件的任何其他引用。以下代码可能对您有帮助。
您可能希望将
Me.
更改为您的工作表名称和目标工作表。According to MSDN a
Graphic
loads the Image through a file (filename). TheFilename
should contain the whole path to the file like 'C:\myimage.jpg' but once the worksheet is saved it changed the filename to 'myiamge' without the path and the extension. I wasn't able to find any other Reference to the file within Excel.The following code might help you.
You might want to change
Me.
to the Name of your Sheet and the Destination Sheet.在 2007 年之前的 Excel 版本中,您无法从页脚中提取图形。您需要拥有原始图像文件。
有关更多详细信息,请参阅上一个问题
In Excel versions prior to 2007, you cannot extract the graphic from the footer. You would need to have the original image file.
See this previous question for more details