




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
實用文檔第頁竭誠為您提供優質文檔/雙擊可除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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 核電池行業商業計劃書
- 2025年超臨界CO2萃取裝置膜生物反應器及其他項目可行性分析報告
- 招標文件里合同協議書
- 短期投資合同協議書范本
- 勞動合同返聘協議書
- 德州5G+文化旅游項目商業計劃書
- 一起肉雞傳染性支氣管炎和大腸桿菌病混合發病的診治
- 燒烤學徒合同協議書范本
- 2025年軟管隔膜活塞泵市場分析報告
- 中醫遠程醫療運營方案
- 古希臘文明智慧樹知到期末考試答案章節答案2024年復旦大學
- 2024年廣東省廣州市天河區七年級(下)期末數學試卷含答案
- DZ∕T 0399-2022 礦山資源儲量管理規范(正式版)
- 離婚糾紛-模擬法庭劇本
- 管培生(校招生)培養方案(計劃)落地完整版
- MOOC 計算機系統局限性-華東師范大學 中國大學慕課答案
- 六年級語文總復習課《修改病句》修改課件市公開課一等獎省賽課獲獎課件
- 位置度公差及其計算課件
- SJ-T 11841.2.2-2022 顯示系統視覺舒適度 第2-2部分:平板顯示-藍光測量方法
- 門診護士培訓課件
- 2024年中國檢驗認證集團福建有限公司招聘筆試參考題庫含答案解析
評論
0/150
提交評論