VBA中怎么把Excel的图片复制到word文件中???
经测试编写VBA代码如下:Sub 嵌入式图片加边框()Application.ScreenUpdating = FalseDim a As IntegerDim pic As InlineShapeDim aBorder As Bordera = ActiveDocument.InlineShapes.CountIf a = 0 ThenMsgBox ("没有发现嵌入式图片")End IfFor Each pic In ActiveDocument.InlineShapespic.Borders.Enable = TrueWith picFor Each aBorder In pic.BordersWith aBorder.LineWidth = wdLineWidth025pt.Color = wdColorBlueEnd WithNext aBorder.ScaleHeight = 100.ScaleWidth = 100End WithNextApplication.ScreenUpdating = TrueEnd SubSub 取消边框()Dim a As Integera = ActiveDocument.InlineShapes.CountIf a = 0 ThenMsgBox ("没有发现嵌入式图片")End IfActiveDocument.InlineShapes(1).Borders.Enable = FalseEnd SubPrivate Sub CommandButton1_Click()嵌入式图片加边框End SubPrivate Sub CommandButton2_Click()取消边框End Sub效果如下:
word如何批量改图片格式
把图片缩小一半就行吧:打开Word文档——按Alt+F11出现VBA窗口——点左上方的Porject项下的“ThisDocument”——右键——插入——模块:粘贴下面的代码:Sub Macro()For Each iShape In ActiveDocument.InlineShapesiShape.Height = iShape.Height * 0.5iShape.Width = iShape.Width * 0.5Next iShapeEnd Sub按F5运行一次就行。
转载请注明出处51数据库 » vba word粘贴图片