我写了一个宏,它将Excel中的图表复制粘贴到一个打开的Word文档中。
用户两次运行宏时会出现问题。在第二轮中,刚刚粘贴的图像仍然被选中,因此新粘贴通过粘贴当前选择来撤消之前的工作。
在宏的末尾附近,如何取消选中我刚刚粘贴的图片,以便下一个宏运行正常工作并粘贴到右边?
我的示例代码:
Private Sub ActiveChartPasteToWordMacro(ByVal AndShrinkItToo)
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim WordCurrentPlace As Word.Range
' Copy the range as a picture
Call ActiveChart.CopyPicture(Appearance:=xlScreen, Size:=xlScreen, Format:=xlBitmap)
' Refer to the current place in the open Word document:
Set WordApp = GetObject(, "Word.Application")
Set WordDoc = WordApp.ActiveDocument
Set WordCurrentPlace = WordApp.Selection.Range
' Paste the Excel chart into Word
Call WordCurrentPlace.Paste
' The user usually calls the macro with some rescaling factor, to fit three charts in a row in Word:
If AndShrinkItToo Then
Call WordApp.Selection.Expand(wdParagraph)
WordApp.Selection.InlineShapes(WordApp.Selection.InlineShapes.count).ScaleWidth = 67
WordApp.Selection.InlineShapes(WordApp.Selection.InlineShapes.count).ScaleHeight = 67
End If
' ???? HOW DO I NOW SELECT THE SPACE AFTER THE IMAGE FOR THE NEXT RUN OF THE MACRO ????
' Clean up
Set WordCurrentPlace = Nothing
Set WordDoc = Nothing
Set WordApp = Nothing
End Sub
答案 0 :(得分:0)
我想我找到了它。答案是添加行public String getSourceEndpoint() {
return sourceEndpoint;
}
答案 1 :(得分:-1)
实际上,有点难以看清你的代码在做什么......其他的调用究竟做了什么?
但请在粘贴之前/之后尝试此操作:WordCurrentPlace.Collapse wdCollapseEnd
答案 2 :(得分:-1)
这里是并排粘贴的代码
更正图片的路径,然后使用F8键
单步执行代码re.compile