复制在多个单元格中旋转并粘贴

发布于 2025-01-22 04:08:02 字数 590 浏览 0 评论 0原文

我正在使用Excel VBA函数来生成条形码作为图像,并将其粘贴在两个单元格中。

只有第一个糊状是旋转的,而不是第二个糊状物。

Set xObjOLE = ActiveSheet.OLEObjects.Add("BARCODE.BarCodeCtrl.1")
xObjOLE.Object.Style = 7
xObjOLE.Object.Value = "0123456789"
xObjOLE.Width = 120
xObjOLE.Height = 30
xObjOLE.CopyPicture xlScreen, xlPicture

Set xRRg = Application.Range("H5")
ActiveSheet.Paste xRRg
With Selection
    .ShapeRange.Rotation = 270
End With

Set xRRg = Application.Range("S5")
ActiveSheet.Paste xRRg
With Selection
    .ShapeRange.Rotation = 270
End With

xObjOLE.Delete

I am using an Excel VBA function to generate a barcode as image and paste it with rotation in two cells.

Only the first paste is rotated and not the second one.

Set xObjOLE = ActiveSheet.OLEObjects.Add("BARCODE.BarCodeCtrl.1")
xObjOLE.Object.Style = 7
xObjOLE.Object.Value = "0123456789"
xObjOLE.Width = 120
xObjOLE.Height = 30
xObjOLE.CopyPicture xlScreen, xlPicture

Set xRRg = Application.Range("H5")
ActiveSheet.Paste xRRg
With Selection
    .ShapeRange.Rotation = 270
End With

Set xRRg = Application.Range("S5")
ActiveSheet.Paste xRRg
With Selection
    .ShapeRange.Rotation = 270
End With

xObjOLE.Delete

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

咋地 2025-01-29 04:08:02

我的第一个建议是旋转原始图像,然后将其粘贴到两个地方。

另一种选择是选择副本,但是为此,我需要知道您是否有文件中的其他图像。

第一个解决方案

为了使其可再现,我仅添加了“集合”块的代码。鉴于此,您需要先选择一个图像,然后运行我的代码。

Sub MacroCopy()
    'Rotate first
    Selection.ShapeRange.Rotation = 270
    Selection.CopyPicture xlScreen, xlPicture


    Set xRRg = Application.Range("H5")
    ActiveSheet.Paste xRRg
    
    Set xRRg = Application.Range("S5")
    ActiveSheet.Paste xRRg
    
    'If you need to rotate back to zero
    Selection.ShapeRange.Rotation = 0

End Sub

如果您有任何疑问,请告诉我。

my first suggestion is rotating the original image, then paste it in two places.

The alternative is selecting the copies, but for that I need to know if you have other images in the file.

First solution

To make it reproducible I am adding only the code for the "Set" chunk. Given that, you need to select an image first, then run my code.

Sub MacroCopy()
    'Rotate first
    Selection.ShapeRange.Rotation = 270
    Selection.CopyPicture xlScreen, xlPicture


    Set xRRg = Application.Range("H5")
    ActiveSheet.Paste xRRg
    
    Set xRRg = Application.Range("S5")
    ActiveSheet.Paste xRRg
    
    'If you need to rotate back to zero
    Selection.ShapeRange.Rotation = 0

End Sub

Please let me know if you have any question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文