版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
实用文档第页竭诚为您提供优质文档/双击可除vba,word表格插入图片
篇一:Vba统一处理woRd中的图片大小
subadjustpicwidthandheight()
alte
adjustpicwidthandheight宏
dimn,m
dimblnisinlineshapeasboolean
dimmylineshapeasinlineshape
onerrorResumenext忽略错误
Foreachmylineshapeinactivedocument.inlineshapes
ifmylineshape.height>mylineshape.widththen
selection.inlineshapes.converttoshape
selection.shapeRange.incrementRotation90
endif
next
Forn=1toactivedocument.inlineshapes.countinlineshapes类型的图片
h=activedocument.inlineshapes(n).height
w=activedocument.inlineshapes(n).width
activedocument.inlineshapes(n).lockaspectRatio=msoFalse不锁定图片的纵横比ifh>wthen
blnisinlineshape=ture
selection.inlineshapes(n).converttoshape
selection.shapeRange.incrementRotation-90
endif
nextn
m=activedocument.inlineshapes.count
Forn=1to2inlineshapes类型的图片
activedocument.inlineshapes(n).lockaspectRatio=msoFalse不锁定图片的纵横比
activedocument.inlineshapes(n).height=153设置图片高度为243px
activedocument.inlineshapes(n).width=243设置图片高度为153px
activedocument.inlineshapes(n).Range.paragraphs(1).Range.paragraphFormat.characterunitFirstlineindent=0
activedocument.inlineshapes(n).Range.paragraphs(1).Range.paragraphFormat.Firstlineindent=0
activedocument.inlineshapes(n).Range.paragraphs(1).Range.paragraphFormat.alignment=wdalignparagraphcenter
nextn
Forn=1to2inlineshapes类型的图片
activedocument.shapes(n).lockaspectRatio=msoFalse不锁定图片的纵横比activedocument.shapes(n).height=153设置图片高度为153px
activedocument.shapes(n).width=243设置图片高度为243px
nextn
Forn=3tominlineshapes类型的图片
activedocument.inlineshapes(n).lockaspectRatio=msoFalse不锁定图片的纵横比activedocument.inlineshapes(n).height=297设置图片高度为297px
activedocument.inlineshapes(n).width=405设置图片高度为405px
nextn
Forn=3tominlineshapes类型的图片
activedocument.shapes(n).lockaspectRatio=msoFalse不锁定图片的纵横比activedocument.shapes(n).height=297设置图片高度为297px
activedocument.shapes(n).width=405设置图片高度为405px
nextn
withselection.paragraphFormat
.leftindent=centimeterstopoints(0)
.Rightindent=centimeterstopoints(0)
.spacebefore=50
.spacebeforeauto=False
.spaceafter=50
.spaceafterauto=False
.linespacingRule=wdlinespacemultiple
.linespacing=linestopoints(3)
.alignment=wdalignparagraphcenter
.widowcontrol=False
.keepwithnext=False
.keeptogether=False
.pagebreakbefore=False
.nolinenumber=False
.hyphenation=true
.Firstlineindent=centimeterstopoints(0)
.outlinelevel=wdoutlinelevelbodytext
.characterunitleftindent=0
.characterunitRightindent=0
.characterunitFirstlineindent=0
.lineunitbefore=10
.lineunitafter=10
.mirrorindents=False
.textboxtightwrap=wdtightnone
.autoadjustRightindent=true
.disablelineheightgrid=False
.Fareastlinebreakcontrol=true
.wordwrap=true
.hangingpunctuation=true
.halfwidthpunctuationontopofline=False
.addspacebetweenFareastandalpha=true
.addspacebetweenFareastanddigit=true
.baselinealignment=wdbaselinealignauto
endwith
endsub
sub处理扫描照片()
处理扫描照片宏
dimn,m
dimblnisinlineshapeasboolean
dimmylineshapeasinlineshape
onerrorResumenext忽略错误
m=activedocument.inlineshapes.count
Forn=1to2inlineshapes类型的图片
activedocument.inlineshapes(n).lockaspectRatio=msoFalse不锁定图片的纵横比activedocument.inlineshapes(n).height=153设置图片高度为243px
activedocument.inlineshapes(n).width=243设置图片高度为153px
nextn
Forn=1to2inlineshapes类型的图片
activedocument.shapes(n).lockaspectRatio=msoFalse不锁定图片的纵横比activedocument.shapes(n).height=153设置图片高度为153px
activedocument.shapes(n).width=243设置图片高度为243px
nextn
Forn=3tominlineshapes类型的图片
activedocument.inlineshapes(n).lockaspectRatio=msoFalse不锁定图片的纵横比activedocument.inlineshapes(n).height=297设置图片高度为297px
activedocument.inlineshapes(n).width=405设置图片高度为405px
nextn
Forn=3tominlineshapes类型的图片
activedocument.shapes(n).lockaspectRatio=msoFalse不锁定图片的纵横比activedocument.shapes(n).height=297设置图片高度为297px
activedocument.shapes(n).width=405设置图片高度为405px
nextn
withselection.paragraphFormat
.leftindent=centimeterstopoints(0)
.Rightindent=centimeterstopoints(0).spacebefore=50
.spacebeforeauto=False
.spaceafter=50
.spaceafterauto=False
.linespacingRule=wdlinespacemultiple.linespacing=linestopoints(3)
.alignment=wdalignparagraphcenter.widowcontrol=False
.keepwithnext=False
.keeptogether=False
.pagebreakbefore=False
.nolinenumber=False
.hyphenation=true
.Firstlineindent=centimeterstopoints(0).outlinelevel=wdoutlinelevelbodytext.characterunitleftindent=0
.characterunitRightindent=0
.characterunitFirstlineindent=0.lineunitbefore=10
.lineunitafter=10
.mirrorindents=False
.textboxtightwrap=wdtightnone.autoadjustRightindent=true
.disablelineheightgrid=False
.Fareastlinebreakcontrol=true.wordwrap=true
.hangingpunctuation=true
.halfwidthpunctuationontopofline=False.addspacebetweenFareastandalpha=true.addspacebetweenFareastanddigit=true.baselinealignment=wdbaselinealignautoendwith
endsub
篇二:excel批量插入图片Vba代码
excel批量插入图片Vba代码(20xx-06-2408:56:26)转载标签:excel批量插入图片代码杂谈
在要插入图片的文件夹里新建一个excel文件,打开这个excel文件,在要插入图片的单元格里填上图片文件名(不要扩展名),选中要插入图片的单元格,修改单元格的大小以显示所需要的图片大小,运行宏代码。
1、alt+F11调取Vba编辑窗口,查看代码,将以下代码全部复制进去;
2、关闭Vba窗口,excel-视图-宏-查看宏;
3、book1.xls!sheet1.insertpic,选中所要插入图片的单元格,执行;
4、图片自动插入对应的单元格中。(图片尺寸均可通过单元格大小进行调解,边框可设置)
代码如下:
subinsertpic()
宏由万加美酒编写,时间:20xx-6-1
dir函数批量获取指定目录下所有文件名和内容
onerrorResumenext
application.screenupdating=False关闭屏幕更新
dimmRasRange
ForeachmRinselection
ifnotisempty(mR)anddir(activeworkbook.path当前文件所在目录下以当前单元内容为名称的.jpg图片
endif
next
setmR=nothing
application.screenupdating=true开启屏幕更新
endsub
我想"按一下按钮,插入图片"
我的vbacode如下:
subpicture_click_062020xx()
x=cells(8,4).Value
chdir"c:\users\myname\desktop\picture\"
activesheet.pictures.insert"x"+".jpg"
endsub
***cells(8,4)的值是图片的名称
我的vbacode有错...
activesheet.pictures.insert("c:\users\myname\desktop\picture\"
dummydoloop
Fori=65to66:Forj=65to66:Fork=65to66
Forl=65to66:Form=65to66:Fori1=65to66
Fori2=65to66:Fori3=65to66:Fori4=65to66
Fori5=65to66:Fori6=65to66:Forn=32to126
withactiveworkbook
.unprotectchr(i)bypassallfor...nexts
endif
endwith
next:next:next:next:next:next
next:next:next:next:next:next
loopuntiltrue
onerrorgoto0
endif
ifwintagandnotshtagthen
msgboxmsgonlyone,vbinformation,headeR
exitsub
endif
onerrorResumenext
Foreachw1inworksheets
attemptclearancewithpword1
w1.unprotectpword1
nextw1
onerrorgoto0
shtag=False
Foreachw1inworksheets
checksforallclearshtagtriggeredto1ifnot.
shtag=tectcontents
nextw1
ifshtagthen
Foreachw1inworksheets
withw1
tectcontentsthen
onerrorResumenext
dodummydoloop
Fori=65to66:Forj=65to66:Fork=65to66
Forl=65to66:Form=65to66:Fori1=65to66
Fori2=65to66:Fori3=65to66:Fori4=65to66
Fori5=65to66:F
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二年级上册语文期末测试卷及答案【新版】
- 部编版七年级地理上册期末试卷【参考答案】
- 新北师大版三年级数学上册全册课件【完整版】
- CHT 4017-2012 矢量地图符号制作规范
- 2024北京市大兴区高二(下)期中英语试卷及答案
- 2022新部编人教版四年级上册《道德与法治》期末试卷(带答案)
- 部编版四年级上册语文期末考试卷及答案【完整版】
- 2023年部编版八年级语文上册期末考试卷(下载)
- 人教版五年级语文上册期末考试卷及答案【一套】
- 2022年一年级语文上册期末考试题(完整版)
- CPK-数据自动生成器
- 项目档案归档整理
- 第七次全国人口普查数据分析报告(可编辑含源数据)课件
- 语文人教版六年级下册《红岩》阅读课-红岩精神教学课件2
- 银行人力资源管理体系
- 沪教版初中数学七年级上册第9-11章思维导图
- 链传动课件专业知识
- 安藤忠雄4x4住宅分析
- 色盲检测图(俞自萍第六版)
- 养老护理员职业道德规范
- 2023学年完整公开课版《战国策》简介
评论
0/150
提交评论