- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在自动从PowerPoint和Excel电子表格中生成PowerPoint报表。在粘贴表格之前,我已经完成了整个过程。
我使用PPApp.CommandBars.ExecuteMso ("PasteSourceFormatting")
将表格粘贴到PowerPoint,表格在幻灯片上显示为一个形状(第三个形状)。
为了引用新的形状,我正在使用Set pShape = Slide2.Shapes(Slide2.Shapes.Count)
,但是现在粘贴时,将pShape
分配为“形状2”(而不是“形状3”)。在粘贴和分配对象之间是否需要做些什么?
下面的代码,注释发生问题的位置。 (已删除完整代码;可见的here)
'Copy tables from Excel
Set rng = ws.Range("A:A")
rng.ColumnWidth = 22.75
Set rng = ws.Range("A4:C27")
'Copy the table range
Application.CutCopyMode = False
rng.Copy
Application.Wait (Now + TimeValue("0:00:02"))
'The issue occurs here!!! '-------------------------------------
'Paste the table in to the slide
Slide2.Select
PPApp.CommandBars.ExecuteMso ("PasteSourceFormatting")
'Name the new shape object
Set pShape = Slide2.Shapes(Slide2.Shapes.Count)
pShape.Name = "Slide_2_Table_1"
pShape.LockAspectRatio = False
最佳答案
'Shapes.Count'≠形状索引#!.Count
与当前形状.Index
编号的上限不同。
通过列出文档中的所有形状,可以更容易地理解编号系统:
Sub ListShapes()
'hit CTRL+G to view output in Immediate Window
Dim sh As Shape, sld As Slide, idx As Long
Set sld = ActivePresentation.Slides(1) '<-- change to your slide number
For Each sh In sld.Shapes
idx = idx + 1
Debug.Print "Shape ID#" & sh.Id, "Index #" & idx, "Name: " & sh.Name
Next sh
Debug.Print "Count of shapes: " & sld.Shapes.Count
End Sub
Insert
手动添加一个矩形
Illustrations
],然后单击
Shapes
和矩形符号。
Shape ID#2 Index #1 Name: Rectangle 1
Shape ID#3 Index #2 Name: Rectangle 2
Shape ID#4 Index #3 Name: Rectangle 3
Shape ID#5 Index #4 Name: Rectangle 4
Shape ID#6 Index #5 Name: Rectangle 5
Count of shapes: 5
For Each..Next
语句返回的顺序相同)。
Debug.Print ActivePresentation.Slides(1).Shapes(5).Name
Rectangle 5
。
Stop
,然后突出显示
ws.Shapes
,右键单击它,选择
Add Watch...
,然后单击“确定”。浏览树以发现文档中形状的各种属性/属性。
Shape ID#2 Index #1 Name: Rectangle 1
Shape ID#3 Index #2 Name: Rectangle 2
Shape ID#5 Index #3 Name: Rectangle 4
Shape ID#6 Index #4 Name: Rectangle 5
Count of shapes: 4
ID
和
Name
不变,但索引已重新编号以反映新的“顺序”。
Rectangle 5
我们现在需要使用:
Debug.Print ActivePresentation.Slides(1).Shapes(4).Name
.Shapes(𝔁)
,是指形状索引编号𝔁,而不是
ID
数字。索引号是根据需要动态分配的,因此不是稳定的引用形状的方法。
.Count
与形状索引号无关。
.Name
或
.ID
数字引用形状。如果动态生成形状,则理想情况下,最好将形状列表存储在数组或集合中,以便可以根据需要查看该列表。
Function idxLastShape(slideNum As Long) As Long
Dim sh As Shape
For Each sh In ActivePresentation.Slides(slideNum).Shapes
idxLastShape = idxLastShape + 1
Next sh
End Function
Debug.Print idxLastShape(1) 'Returns index of last shape on slide#1
Function LastShape(slideNum As Long) As Shape
Dim sh As Shape
For Each sh In ActivePresentation.Slides(slideNum).Shapes
Set LastShape = sh
Next sh
End Function
Debug.Print LastShape(1).Name
LastShape(1).Delete
.Type
对象的
Shape
属性以及其他方法来过滤由这些过程枚举的形状。部分列表
here,并且在下面的链接中有更多信息。
Sub ListShapes()
'hit CTRL+G to view output in Immediate Window
Dim sh As Shape, ws As Worksheet, idx As Long
Set ws = Sheets("Sheet1") '<-- change to your worksheet name
For Each sh In ws.Shapes
idx = idx + 1
Debug.Print "Shape ID#" & sh.ID, "Index #" & idx, "Name: " & sh.Name
Next sh
Debug.Print "Count of shapes: " & Sheets("Sheet1").Shapes.Count
End Sub
Function idxLastShape(shtName As String) As Long
Dim sh As Shape
For Each sh In Sheets(shtName).Shapes
idxLastShape = idxLastShape + 1
Next sh
End Function
Debug.Print idxLastShape("Sheet1")
Function LastShape(shtName As String) As Shape
Dim sh As Shape
For Each sh In Sheets(shtName).Shapes
Set LastShape = sh
Next sh
End Function
Debug.Print LastShape("Sheet1").Name
Shapes
Object (PowerPoint/VBA)
Shapes
Object (Excel/VBA)
关于excel - 粘贴的形状不被视为“最新”形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51169904/
我正在遵循一个教程,老师通过以下方式将 html 粘贴到我们的 scrappy shell 中:%paste (下面的 html) html_doc = " " Title of hte page
例如 1.1.1.1 a.com 2.1.1.1 b.com 1.3.1.1 c.com 1.1.5.1 d.com 1.2.1.1 e.com 现在我想从另一个文本中替换这个 ip,不一样
是否有机会在 Angular 中实现粘贴按钮。 FE:用户复制网站的链接,当他或她点击按钮时,在我的页面上复制的链接应该出现在文本框中。 谢谢! 最佳答案 您只能以编程方式从网页复制。您不能以编程方式
我正在尝试提高 Vim 中粘贴功能的可用性,因为太多不同的删除操作(实际上我认为它们都是这样)也会拉到粘贴缓冲区。 这意味着我不再能够删除一些我想粘贴到某处的文本,清理一些东西,以及。然后 做我的粘贴
我正在构建一个简单的 Electron 应用程序,以在屏幕上的其他所有内容上显示一些文本。 有一个键盘快捷键可以打开带有文本的弹出窗口。 我想添加一个小功能。 最好的情况是:在计算机上的任意位置选择一
我有一个双击事件,我希望它保存特定范围的副本。 Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boo
我已经为这个烦人的问题苦苦挣扎了一段时间,但没有找到一个优雅的解决方案。 假设我有这样一个类层次结构: class StatWithBounds[A](val min: A, val max: A,
现在我有一个 Word 宏,可以通过将图像复制并粘贴到该位置来将图像移动到特定文本前面。这种方法效果很好,但成本很高。如果我的 Word 文档中有 1,000 张图像,则运行宏可能需要 30 分钟。
让我以我是自学成才的事实作为我的问题的开头,所以请提供尽可能详细的信息,如果我需要您以不同的方式或多次解释,请耐心等待。 我使用 Microsoft Visual Basic 7.0 为我的团队创建了
我已经为这个烦人的问题苦苦挣扎了一段时间,但没有找到一个优雅的解决方案。 假设我有这样一个类层次结构: class StatWithBounds[A](val min: A, val max: A,
我正在使用 Meteor 开发一个聊天应用程序,我不希望用户能够出于明显的垃圾邮件原因将内容复制/粘贴到表单中。这可能吗?这是我用来运行聊天应用程序的代码: Javascript: // render
我已经为此搜索了很多,但找不到任何建议...我提供了我自己的经典操作栏实现,所以我在所有 Activity 中声明粘贴/等..有谁知道如何做到这一点? 此外,我将提供我自己的复制/粘贴功能,并且仅在需
Windows 中 SWT Text 的默认上下文菜单有几个我们不想要的选项。由于操作系统提供的默认上下文菜单无法修改,因此我创建了一个自定义上下文菜单,其中只有基本的文本操作,例如文本框的删除、剪切
我最后的问题不是很清楚,我再试一次。 在我的 Tumblr 博客 (http://anti-standard.tumblr.com) 上,您可以看到一张图片(图片上写着“ANTI STANDARD”)
我必须编写一个脚本文件来剪切以下列并将其粘贴到新 .arff 文件中同一行的末尾。我想文件类型无关紧要。 当前文件: 63,male,typ_angina,145,233,t,left_vent_hy
是否可以发送过去的命令,以便将文本粘贴到当前聚焦的编辑文本中。场景: 后台服务监听通知(完成) 收到通知后,需要将文本复制到剪贴板(完成) 将文本粘贴到任何当前聚焦的字段,如果不可能则放弃粘贴命令。
我想用 PIL 粘贴一堆图片。出于某种原因,当我运行 blank.paste(img,(i*128,j*128)) 行时,出现以下错误:ValueError: cannot determine reg
如何在我的网页中禁用复制粘贴功能。准确地说,我不希望我的用户从我的网站上复制任何信息并将其用于个人目的。上一个关于同一主题的问题没有给出足够的解释。 onselect 和 ondrag 不起作用。请帮
废话不多说,直接上代码,小伙伴们仔细看下注释吧。 复制代码代码如下: /*简单的 复制 剪切 粘贴 功能 操作:
我应该在 vimrc 中添加哪一行以便在终端之间或不同文件/选项卡之间轻松复制/粘贴? 我现在有: " Better copy & paste set pastetoggle= set clipboa
我是一名优秀的程序员,十分优秀!