欢迎来到科站长!

office激活

当前位置: 主页 > 网站运营 > office激活

vba设置word图片格式

时间:2025-05-10 15:44:25|栏目:office激活|点击:

一、旋转图片

Dim blnIsInlineShape As Boolean

If Selection.Type = wdSelectionInlineShape Then

blnIsInlineShape = True

Selection.InlineShapes(1).ConvertToShape

End If

Dim intTurn As Integer

intTurn = InputBox("请输入图形要旋转的角度值" & vbCrLf & "正数表示顺时针,负数表示逆时针。", "图形旋转", 30)

Selection.ShapeRange.IncrementRotation intTurn

End Sub

二、将文档中的每张图片的版式转换为嵌入式图形

For Each s In Documents("MyDoc.doc").Shapes

If s.Type = msoPicture Then

s.ConvertToInlineShape

End If

Next s

三、设置图片的高度宽度

Mywidth=10'10为图片宽度(厘米)

Myheigth=10'10为图片高度(厘米)

For Each iShape In ActiveDocument.InlineShapes

iShape.Height = 28.345 * Myheigth

iShape.Width = 28.345 * Mywidth

Next iShape

四、得到图片的像素

Sub 获取嵌入型图片的像素()

On Error Resume Next

With Selection.Range.Find

.ClearFormatting

.Replacement.ClearFormatting

.Execute findtext:="^g", MatchWildcards:=False, Wrap:=wdFindStop

MsgBox "该图片的像素为:" & Selection.InlineShapes(1).Width _

& " * " & Selection.InlineShapes(1).Height

End With

End Sub

五、复制图片到word文档中

Dim objWordApp As Word.Application

Dim objWord As Word.Document

Range(Cells(3, 2), Cells(11, 11)).Select

Selection.CopyPicture

Set objWordApp = CreateObject("Word.Application")

Set objWord = objWordApp.Documents.Add

objWord.Application.Visible = True

objWord.Application.Selection.Paste

Set objWord = Nothing

Set objWordApp = Nothing


上一篇:如何使用Word2010文档中"键入时标记语法错误"功能

栏    目:office激活

下一篇:Word插入脚注后分节符自动变成分页符解决办法

本文标题:vba设置word图片格式

本文地址:https://www.fushidao.cc/wangzhanyunying/13815.html

广告投放 | 联系我们 | 版权申明

申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:257218569 | 邮箱:257218569@qq.com

Copyright © 2018-2025 科站长 版权所有冀ICP备14023439号