--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. Bootstrap列表组

    前面的话 列表组是Bootstrap框架新增的一个组件,可以用来制作列表清单.垂直导航等效果,也可以配合其他的组件制作出更漂亮的组件.本文将详细介绍Bootstrap列表组 基础列表组 基础列表组,看 ...

  2. Oracle的用户、角色以及权限相关操作

    1.创建用户create user KD identified by 123456;2.授予连接数据库的权限grant connect to KD;3.将Scott用户的emp表授权给KD可以查询gr ...

  3. OpenGL的配置与搭建

    一.项目中所使用的OpenGL扩展库有: 1. freeglut-3.0.0 2. glew-2.0.0 3. glm-0.9.7.3 二.添加扩展库文件 在工程项目文件夹里面添加OpenGLExte ...

  4. Eclipse中常用快捷键

    Ctrl+C:复制. Ctrl+V:粘贴. Ctrl+X:剪切. Ctrl+S:保存. Ctrl+Z:撤销. Ctrl+A:全选. F3:快速定位光标位置的某个类.方法和属性. Ctrl+Q:跳到最后 ...

  5. vue数据绑定原理

    一.定义 vue的数据双向绑定是基于Object.defineProperty方法,通过定义data属性的get和set函数来监听数据对象的变化,一旦变化,vue利用发布订阅模式,通知订阅者执行回调函 ...

  6. win10下python2与python3以及pip共存

    一 分别安装python2和python3 注意: 安装时记得勾选 Add Python.exe to Path 二 安装pip Python3最新版本有pip,无需安装 Python2: 下载pip ...

  7. 51nod_1040:最大公约数之和(数论)

    题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1040 给出一个n,求1-n这n个数,同n的最大公约数的和. ...

  8. Nginx文档-初学者指南

    原文档: http://nginx.org/en/docs/beginners_guide.html 译者:Oopsguy 本指南旨在介绍nginx基本内容和一些在Nginx上可以完成的简单任务.这里 ...

  9. 可存放任意类型变量的动态数组--C语言实现

    之前在训练营的时候被要求用C语言实现一个可以存放任意类型数据的栈.现在尝试实现一个数组版本. 首先用到的结构体如下(接触了Win32编程所以长得有点像里面的那些类型): typedef struct ...

  10. 【SpringMVC】【EasyUI】关于使用EasyUIForm上传文件,返回JsonIE提示下载文件的解决办法!

    先说一下环境 EasyUI+SpringMVC+MyBatis 因为按正常手段,无法使用Ajax来提交一个包含文件的表单,故想到利用EasyUI的Form来提交,EasyUI的form封装了一套伪Aj ...