Word 中用VBA插入文本框的方法
时间:2010-12-08
来源:互联网
请教:WORD中如何写“在选定的一段文字前插入文本框”的VBA代码。
谢谢了!
谢谢了!
作者: alanxujian 发布时间: 2010-12-08
Selection.HeaderFooter.Shapes.AddTextbox(msoTextOrientationHorizontal, 750, 70.87, 35, 453.6).Select
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse
Selection.ShapeRange.Select
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0
Selection.ShapeRange.Line.Visible = msoFalse
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = CentimetersToPoints(15.96) '设置文本框高度
Selection.ShapeRange.Width = CentimetersToPoints(20) '设置文本框宽度
Selection.ShapeRange.Left = CentimetersToPoints(25) '设置文本框左边相对位置(厘米转为磅)
Selection.ShapeRange.Top = CentimetersToPoints(0.7) '设置文本框顶边相对位置
Selection.ShapeRange.TextFrame.MarginLeft = 0
Selection.ShapeRange.TextFrame.MarginRight = 0
Selection.ShapeRange.TextFrame.MarginTop = 0
Selection.ShapeRange.TextFrame.MarginBottom = 0
Selection.ShapeRange.RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
Selection.ShapeRange.LockAnchor = False
Selection.ShapeRange.LayoutInCell = True
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceRight = CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder 4
Selection.ShapeRange.TextFrame.AutoSize = False
Selection.ShapeRange.TextFrame.WordWrap = True
Selection.ShapeRange.TextFrame.TextRange.Select '选中文本框内容
Selection.Collapse
Selection.Orientation = wdTextOrientationVerticalFarEast
Selection.TypeText Text:=InputBox("输入页眉")
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse
Selection.ShapeRange.Select
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0
Selection.ShapeRange.Line.Visible = msoFalse
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = CentimetersToPoints(15.96) '设置文本框高度
Selection.ShapeRange.Width = CentimetersToPoints(20) '设置文本框宽度
Selection.ShapeRange.Left = CentimetersToPoints(25) '设置文本框左边相对位置(厘米转为磅)
Selection.ShapeRange.Top = CentimetersToPoints(0.7) '设置文本框顶边相对位置
Selection.ShapeRange.TextFrame.MarginLeft = 0
Selection.ShapeRange.TextFrame.MarginRight = 0
Selection.ShapeRange.TextFrame.MarginTop = 0
Selection.ShapeRange.TextFrame.MarginBottom = 0
Selection.ShapeRange.RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
Selection.ShapeRange.LockAnchor = False
Selection.ShapeRange.LayoutInCell = True
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceRight = CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder 4
Selection.ShapeRange.TextFrame.AutoSize = False
Selection.ShapeRange.TextFrame.WordWrap = True
Selection.ShapeRange.TextFrame.TextRange.Select '选中文本框内容
Selection.Collapse
Selection.Orientation = wdTextOrientationVerticalFarEast
Selection.TypeText Text:=InputBox("输入页眉")
作者: dongfangeia 发布时间: 2010-12-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28