--VBS脚本插入excel图片
-------------------------2013/11/23
根据第一列的值,需找对应的图片,然后插入的指定的列中,图片根据列的长宽信息决定图片大小。
代码1图片正常状态,不旋转
Dim fso
Wscript.StdOut.WriteLine "*********************************************** "
Wscript.StdOut.WriteLine "* AUTO INSERT WIN BOTTLE PICTURE * "
Wscript.StdOut.WriteLine "* FOR VICKY * "
Wscript.StdOut.WriteLine "* version 1.0 2013/11/23 * "
Wscript.StdOut.WriteLine "*********************************************** "
Wscript.StdOut.WriteLine ""
Wscript.StdOut.WriteLine ""
Wscript.StdOut.WriteLine "Please Input which Colunm that you want to insert the pictures ? " excelname=inputbox("Please Input the dirction and file name of the excel you want to process:")
no=cdbl(inputbox("Please Input which Colunm that you want to insert the pictures:")) Set fso=CreateObject("Scripting.FileSystemObject")
Set xlapp = CreateObject("Excel.Application")
Set xlbook = Nothing
Set xlsheet = Nothing
Set xlbook = xlapp.Workbooks.Open(excelname)
Set xlsheet = xlbook.Worksheets() intRow = '''''''''''''''''''''''如果不想从第二行开始插入,可以修改参数intRow Do Until xlsheet.Cells(intRow,).Value = "" bottle_no=xlsheet.Cells(intRow,).Value
xlapp.Visible = False
xlsheet.Cells(intRow,no).Select Tpic = "d:\"&bottle_no&".jpg" '''''''''''''''''''在这里修改图片的文件夹路径 If fso.fileExists(Tpic) Then set MyPic = xlsheet.Pictures.Insert(Tpic) MyPic.ShapeRange.Width=xlsheet.Cells(intRow,no+).Left-xlsheet.Cells(intRow,no).Left-
MyPic.ShapeRange.Height=xlsheet.Cells(intRow+,no).Top-xlsheet.Cells(intRow,no).Top- MyPic.ShapeRange.Left=xlsheet.Cells(intRow,no).Left+((xlsheet.Cells(intRow,no+).Left-xlsheet.Cells(intRow,no).Left-MyPic.ShapeRange.Width)/)
MyPic.ShapeRange.Top=xlsheet.Cells(intRow,no).Top+ End If intRow = intRow + Loop xlbook.Save()
xlbook.Close()
xlapp.Quit Wscript.StdOut.WriteLine ""
Wscript.StdOut.WriteLine ""
Wscript.StdOut.WriteLine "Pictures Inserting finished, press any key to exit !!!"
Wscript.StdIn.ReadLine


设置图片旋转为横向:
Dim fso
Wscript.StdOut.WriteLine "*********************************************** "
Wscript.StdOut.WriteLine "* AUTO INSERT WIN BOTTLE PICTURE * "
Wscript.StdOut.WriteLine "* FOR VICKY * "
Wscript.StdOut.WriteLine "* version 1.0 2013/11/23 * "
Wscript.StdOut.WriteLine "*********************************************** "
Wscript.StdOut.WriteLine ""
Wscript.StdOut.WriteLine ""
Wscript.StdOut.WriteLine "Please Input which Colunm that you want to insert the pictures ? " excelname=inputbox("Please Input the dirction and file name of the excel you want to process:")
no=cdbl(inputbox("Please Input which Colunm that you want to insert the pictures:")) Set fso=CreateObject("Scripting.FileSystemObject")
Set xlapp = CreateObject("Excel.Application")
Set xlbook = Nothing
Set xlsheet = Nothing
Set xlbook = xlapp.Workbooks.Open(excelname)
Set xlsheet = xlbook.Worksheets() intRow = '''''''''''''''''''''''如果不想从第二行开始插入,可以修改参数intRow Do Until xlsheet.Cells(intRow,).Value = "" bottle_no=xlsheet.Cells(intRow,).Value
xlapp.Visible = False
xlsheet.Cells(intRow,no).Select Tpic = "d:\"&bottle_no&".jpg" '''''''''''''''''''在这里修改图片的文件夹路径 If fso.fileExists(Tpic) Then set MyPic = xlsheet.Pictures.Insert(Tpic)
MyPic.ShapeRange.IncrementRotation MyPic.ShapeRange.Height=xlsheet.Cells(intRow,no+).Left-xlsheet.Cells(intRow,no).Left-
MyPic.ShapeRange.Width=xlsheet.Cells(intRow+,no).Top-xlsheet.Cells(intRow,no).Top- MyPic.ShapeRange.Left=xlsheet.Cells(intRow,no).Left+((xlsheet.Cells(intRow,no+).Left-xlsheet.Cells(intRow,no).Left-MyPic.ShapeRange.Width)/)
MyPic.ShapeRange.Top=xlsheet.Cells(intRow,no).Top-((MyPic.ShapeRange.Height-xlsheet.Cells(intRow+,no).Top+xlsheet.Cells(intRow,no).Top)/) End If intRow = intRow + Loop xlbook.Save()
xlbook.Close()
xlapp.Quit Wscript.StdOut.WriteLine ""
Wscript.StdOut.WriteLine ""
Wscript.StdOut.WriteLine "Pictures Inserting finished, press any key to exit !!!"
Wscript.StdIn.ReadLine

相关信息:
console中输入数字:no = cdbl(Wscript.StdIn.ReadLine)
选择excel单元格另一种方法:xlsheet.Range("E4").Select

VBS脚本插入excel图片的更多相关文章

  1. Vbs脚本经典教材(转)

    Vbs脚本经典教材(最全的资料还是MSDN) —为什么要使用Vbs? 在Windows中,学习计算机操作也许很简单,但是很多计算机工作是重复性劳动,例如你每周也许需要对一些计算机文件进行复制.粘贴.改 ...

  2. Vbs 脚本编程简明教程之一

    —为什么要使用 Vbs ? 在 Windows 中,学习计算机操作也许很简单,但是很多计算机工作是重复性劳动,例如你每周也许需要对一些计算机文件进行复制.粘贴.改名.删除,也许你每天启动 计算机第一件 ...

  3. Vbs脚本经典教材

    转载:http://www.cnblogs.com/BeyondTechnology/archive/2011/01/10/1932440.html Vbs脚本经典教材(最全的资料还是MSDN) —为 ...

  4. 用VBS脚本发邮件

    需求是这样的:针对账号的管理,如果发现该账号的管理员给账号加了批注,(比如要过期,修改密码,完善资料等),就需要找到这样的账号及其管理的邮件,然后发邮件给他们的管理员同时抄送给账号以达到提醒的目的.那 ...

  5. VBS脚本实例

    一.一键升级哨位台核心板程序脚本. ############################################################ Set ws=WScript.Create ...

  6. VBS脚本随笔

    1.定时运行程序与关闭程序的VBS处理方法: do set ws=createobject("wscript.shell") ws.run"你要运行的程序的路径(比如说d ...

  7. C#/VB.NET对EXCEL图片添加超链接

    在日常工作中,在编辑文档时,为了方便自己或者Boss能够实时查看到需要的网页或者文档是,需要对在Excel中输入的相关文字进行超链接,那么对于一些在Excel中插入的图片我们该怎么实现超链接呢,下面给 ...

  8. Windows系统使用vbs脚本或bat脚本强制杀死指定所有进程 vbs实现循环持续写入内容到vbs打开开的记事本 使用vbs、bat添加windows计划任务 使用cmd schtasks命令添加windows计划任务

    以下脚本windows7下成功运行过,脚本也可以windows计划任务程序一起组合使用 新建一个记事本文档粘贴下面代码后将新建的记事本文档重命名下面对应的脚本名就能使用了: 添加windows计划任务 ...

  9. 数据测试001:利用python连接数据库插入excel数据

    数据测试001:利用python连接数据库插入excel数据 最近在做数据测试,主要是做报表系统,需要往数据库插入数据验证服务逻辑,本次介绍如何利用python脚本插入Oracle和Mysql库中: ...

随机推荐

  1. Linux 多用户系统

    Linux OS是基于Unix系统开发而来,我们知道计算机是昂贵与稀缺的资源,所以一台计算机就要满足多个用户同时使用,即多用户的系统的思想. 实现方式:通过分时共享的策略.即让多个用户可以同时使用一台 ...

  2. UNITY VR 视频/图片 开发心得(一)

    现在的VR似乎没有之前那么火热了,于是乎我居然开始了VR征程... 说起VR,对于没有接受过相关知识的人来说可能看起来比较高大上,但是VR的原理却没有想象中那么复杂.总的来说,VR之所以能够产生立体感 ...

  3. jquery.validata.js 插件

    一.Validate插件描述 Validate是基于jQuery的一款轻量级验证插件,内置丰富的验证规则,还有灵活的自定义规则接口,HTML.CSS与JS之间的低耦合能让您自由布局和丰富样式,支持in ...

  4. Vysor破解助手for Linux/macOS/Windows

    Vysor更新到1.7.8后,之前的破解工具又失效了,但破解的方法依然可用.在更新破解工具的过程中,Vysor又出了1.7.9版本,主要是对Android O做了处理.更新后的破解工具支持1.6.6~ ...

  5. P1280 尼克的任务

    题目描述 尼克每天上班之前都连接上英特网,接收他的上司发来的邮件,这些邮件包含了尼克主管的部门当天要完成的全部任务,每个任务由一个开始时刻与一个持续时间构成. 尼克的一个工作日为N分钟,从第一分钟开始 ...

  6. int-整数+bool-布尔功能介绍

    int #创建和转换 #a = 123#a = int(123)#转换 #Age = "22"#Age = int(22)#1.当前整数用二进制表示的最小位数 # age = 50 ...

  7. React Native之APK文件签名及打包

    生成apk签名文件 我们使用android studio的方式进行签名 AS工具栏找到并点击 build->gennrate signed apk 两种情况: 1.这里如果已经有签名文件了则直接 ...

  8. js 设置下拉框的默认值

    设置下拉框的默认值,直接在option中增加selected就可以了.但是现在要使用JS来设置它的默认值,代码如下: <select name="aaa" id=" ...

  9. java 使用spring实现读写分离

    最近上线的项目中数据库数据已经临近饱和,最大的一张表数据已经接近3000W,百万数据的表也有几张,项目要求读数据(select)时间不能超过0.05秒,但实际情况已经不符合要求,explain建立索引 ...

  10. Python爬虫番外篇之Cookie和Session

    关于cookie和session估计很多程序员面试的时候都会被问到,这两个概念在写web以及爬虫中都会涉及,并且两者可能很多人直接回答也不好说的特别清楚,所以整理这样一篇文章,也帮助自己加深理解 什么 ...