当前位置:网站首页>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++;
}
边栏推荐
- pyQt 常用系统的事件
- Vulnhub target: boredhackerblog: social network
- Swift extension networkutil (network monitoring) (source code)
- Phonics
- Learning event binding of 3D visualization from scratch
- Ad-gcl:advantageous graph augmentation to improve graph contractual learning
- 论文笔记: 多标签学习 DM2L
- SQL intra statement operation
- 1279_ Vsock installation failure resolution when VMware player installs VMware Tools
- 2022年制冷与空调设备运行操作上岗证题库及模拟考试
猜你喜欢
随机推荐
Decltype usage introduction
decltype用法介绍
不止于观测|阿里云可观测套件正式发布
Online education fades
LabVIEW查找n个元素数组中的质数
Live broadcast review | detailed explanation of koordinator architecture of cloud native hybrid system (complete ppt attached)
软件工程导论——第二章——可行性研究
Vscode topic recommendation
Swift extension networkutil (network monitoring) (source code)
Nodejs redlock notes
SQL intra statement operation
自动化测试的未来趋势
Auto usage example
Analysis of abnormal problems in domain name resolution in kubernetes
C# Lambda
GraphMAE----论文快速阅读
Upgrade Mysql to the latest version (mysql8.0.25)
对于flex:1的详细解释,flex:1
Markdown 实现文内链接跳转
About the iframe anchor, the anchor is offset up and down, and the anchor has page display problems Srcdoc problem of iframe









