当前位置:网站首页>WPS的JS宏实现图片正文在同一段落的分离方法
WPS的JS宏实现图片正文在同一段落的分离方法
2022-06-24 06:57:00 【红狐格格】
当图片处于正文的行尾时,有时候人眼很难判断出来。但是在编辑格式时又很容易出错,图片需要居中处理,正文需要左对齐。
如下JS代码实现了:图文分离
let rangShapes = Documents.Item(filepath).Range(startP,endP).InlineShapes;
while(i<=count)
{
rangShapes.Item(i).Select();
if(rangShapes.Item(i).Height >= Selection.Font.Size*2)
{//图片高度大于正文字体高度的两倍,进行居中处理。否则判定为正文描述内容。
rangShapes.Item(i).Select();
ActiveW.Selection.MoveLeft(wdCharacter, 2, wdExtend);
if(ActiveW.Selection.Paragraphs.Count == 1)
{//图文在同一段落中,在图片前增加回车换行。
rangShapes.Item(i).Select();
ActiveW.Selection.MoveLeft(wdCharacter, 1, wdMove);
ActiveW.Selection.TypeParagraph();
ActiveW.Selection.Style = "正文";
}
rangShapes.Item(i).Select();
ActiveW.Selection.ParagraphFormat.CharacterUnitFirstLineIndent = 0;
ActiveW.Selection.ParagraphFormat.FirstLineIndent = 0;
ActiveW.Selection.ParagraphFormat.CharacterUnitLeftIndent = 0;
ActiveW.Selection.ParagraphFormat.LeftIndent = 0;
ActiveW.Selection.ParagraphFormat.CharacterUnitRightIndent = 0;
ActiveW.Selection.ParagraphFormat.RightIndent = 0;
ActiveW.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter;//图片居中
}
i++;
}
边栏推荐
- Pipeline concept of graphic technology
- Phonics
- Nodejs redlock notes
- Selenium IDE的安装以及使用
- Easyplayerpro win configuration full screen mode can not be full screen why
- 问题4 — DatePicker日期选择器,2个日期选择器(开始、结束日期)的禁用
- Ad-gcl:advantageous graph augmentation to improve graph contractual learning
- 1279_ Vsock installation failure resolution when VMware player installs VMware Tools
- Optimization and practice of Tencent cloud EMR for cloud native containerization based on yarn
- js滚动div滚动条到底部
猜你喜欢

Screenshot recommendation - snipaste

直播回顾 | 云原生混部系统 Koordinator 架构详解(附完整PPT)

For a detailed explanation of flex:1, flex:1

2021-03-04 COMP9021第六节课笔记

Use of swift basic closure /block (source code)

软件工程导论——第二章——可行性研究

Swift Extension ChainLayout(UI的链式布局)(源码)

Synchronous FIFO

Leetcode 207: course schedule (topological sorting determines whether the loop is formed)

Blue Bridge Cup_ Queen n problem
随机推荐
Part 1: building OpenGL environment
1279_ Vsock installation failure resolution when VMware player installs VMware Tools
2021-03-09 COMP9021第七节课笔记
Swift 基礎 閉包/Block的使用(源碼)
Methods of vector operation and coordinate transformation
小样本故障诊断 - 注意力机制代码 - BiGRU代码解析实现
C# Lambda
Review of postgraduate English final exam
13 -- 移除无效的括号
OpenCV get(propId) 常用的值
不止于观测|阿里云可观测套件正式发布
【点云数据集介绍】
Pipeline concept of graphic technology
dhcp、tftp基础
Simple summary of lighting usage
pyQt 中 QMenu 响应
Vscode topic recommendation
[nilm] non intrusive load decomposition module nilmtk installation tutorial
longhorn安装与使用
transformers PreTrainedTokenizer类