首页 > 其他分享 >word 创建宏,根据选取的图片相同的图片

word 创建宏,根据选取的图片相同的图片

时间:2024-03-09 15:44:19浏览次数:24  
标签:InlineShapes word Dim 选取 DeleteCounter ActiveDocument images End 图片

Sub DeleteImages()  
    Dim i As Long  
    Dim SourceWidth As Single  
    Dim SourceHeight As Single  
    Dim DeleteCounter As Long  
  
    ' Check if a picture is selected  
    If Selection.InlineShapes.Count > 0 Then  
        ' Save the dimensions of the source image  
        SourceWidth = Selection.InlineShapes(1).Width  
        SourceHeight = Selection.InlineShapes(1).Height  
    Else  
        MsgBox "No image selected"  
        Exit Sub  
    End If  
  
    ' Initialize DeleteCounter  
    DeleteCounter = 0  
  
    ' Loop backwards through all images in the document  
    For i = ActiveDocument.InlineShapes.Count To 1 Step -1  
        ' Compare the images  
        If SourceWidth = ActiveDocument.InlineShapes(i).Width And SourceHeight = ActiveDocument.InlineShapes(i).Height Then  
            ' Images are the same size, delete the target image and increment DeleteCounter  
            ActiveDocument.InlineShapes(i).Delete  
            DeleteCounter = DeleteCounter + 1  
        End If  
    Next i  
  
    ' Output the number of deleted images  
    MsgBox "Number of deleted images: " & DeleteCounter  
End Sub  

标签:InlineShapes,word,Dim,选取,DeleteCounter,ActiveDocument,images,End,图片
From: https://www.cnblogs.com/holdme/p/18062793

相关文章

  • 前端保存图片
    importReact,{useRef}from'react';importhtml2canvasfrom'html2canvas';constDownloadImage=()=>{constelementRef=useRef(null);consthandleDownload=()=>{constelement=elementRef.current;html2c......
  • css滤镜图片的原样生成
    现在需要对一个复杂滤镜的图片进行保存,使这个图片能保留滤镜的效果。原理很简单,就是在原来image的基础上,新建一个canvas,然后增加滤镜效果,画出这个图片,最后保存这个图片到本地。js代码简单版本(未实现批量)`ApplyFiltertoImage<script>constoriginalImage=document......
  • jsPDF 文字、图片生成PDF(解决中文乱码)
    JSPDF官网在线演示地址(不支持中文)思源黑体字体库下载地址:https://gitee.com/ABCpril/SourceHansTtf   https://github.com/adobe-fonts/source-han-sans/blob/release/README.md (后面一个是完整的包、比较大,一般用前面一种)JSPDF支持中文(思源黑体)采坑之旅,JSPDF中文字体......
  • 映射本地图片
    importorg.springframework.context.annotation.Configuration;importorg.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;importorg.springframework.web.servlet.config.annotation.WebMvcConfigurer;/***映射本地图片类,找到url对应的文件,配置Spr......
  • 把图片插在excel单元格里
    本文以WPS专业版举例1、如下图,选择对应的单元格 2、通过“插入”菜单插入图片或直接粘贴图片3、如下图,对插入的图片点击鼠标右键,选择“切换为嵌入单元格图片”4、完成 ......
  • 从数据库中随机选取数据(基于golang,xorm)
    一、 从MySQL数据库中随机选取数据,可以使用SQL的 ORDERBYRAND() 语句来实现。具体步骤如下:定义一个结构体用于存储数据typeUserstruct{Idint64NamestringAgeint}建立与数据库的连接,并获取一个 Engine 实例engine,err:=xorm.NewE......
  • 在HTML界面显示图片略缩图 , 点击图片放大显示
    HTML样式 <divid="outerdiv"style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;"> <divid="innerdiv"style="position:absolute;"> <imgid=&......
  • 值得收藏的几款免费pdf转成图片的在线工具
    如何将PDF转成图片?在数字化时代,PDF文件已成为我们日常生活和工作中不可或缺的一部分。有时我们也需要将PDF文件转换为图片格式,以便更方便地分享、编辑或打印。接下来为你推荐几款备受好评的PDF转图片在线工具,帮助你轻松转换各种格式文件。1.ilovepdf在线工具中文版ilovepdf中文......
  • androi studio bitmap 压缩后 图片方向异常
    Android使用Camera2拍照后,获得 byte[]data,随后使用 BitmapFactory.decodeByteArray  压缩导致图片方向异常 /**避免出现方向异常**/publicstaticMatrixgetMatrix(byte[]data){ if(Build.VERSION.SDK_INT>=24){ ExifInterfaceexif=null; tr......
  • LNMP+wordpress
    ......