0
点赞
收藏
分享

微信扫一扫

WPS表格 JSA 学习笔记 - 批量测试图片

一天清晨 2022-01-07 阅读 64

创建图片样式

function 创建图片样式(styleName = "图片")
{
	try{
		ActiveDocument.Styles.Item(styleName).Delete();
	}catch(e){
		Console.log("样式不存在");
	}
	ActiveDocument.Styles.Add(styleName, wdStyleTypeParagraph);
	(obj=>{
		obj.Alignment = wdAlignParagraphCenter; // 居中
		obj.IndentCharWidth(0);					// 0缩进
	})(ActiveDocument.Styles.Item(styleName).ParagraphFormat);

}
创建图片样式();

批量设置图片

function 批量设置图片()
{
	var arr = [...ActiveDocument.InlineShapes];
	// 关闭屏幕更新,提升执行效率
	Application.ScreenUpdating = false;
	arr.forEach(shape=>{
		//-------- 设置样式 --------
		if(shape.Type == wdInlineShapePicture){
			shape.Range.Style = "图片";
		}
		//-------- 设置边框 --------
		shape.Line.Visible = msoTrue;						// 显示边框
		//shape.Borders.OutsideLineStyle = wdLineStyleSingle;	// 边框类型
        //shape.Borders.OutsideColorIndex = wdBlack; 			// 边框颜色
        //shape.Borders.OutsideLineWidth = wdLineWidth100pt;	// 边框粗细
	});
	// 开启屏幕更新
    Application.ScreenUpdating = true;	
    Console.log('批量设置【图片】完成。');
}
举报

相关推荐

0 条评论