Wps常用批量操作技巧_第1頁
Wps常用批量操作技巧_第2頁
Wps常用批量操作技巧_第3頁
Wps常用批量操作技巧_第4頁
免費預(yù)覽已結(jié)束,剩余1頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、Wps 常用批量操作技巧對于一些普通的 wps 操作如刪除頁眉、去掉空格等,如果只有幾十個文 檔,大家一般都會, 但是如果文檔有成百上千個呢?一個個去打開更改未免太過 麻煩,我們這里推薦 wps 一款非常強大的自編程工程,即 vb 模板,同樣適用于 office 、word 等,首先需要點擊開發(fā)者工具,找到 vb 編輯器,然后點擊插入模 塊,就可以在輸入框內(nèi)打代碼啦。下面介紹幾種常用的批量代碼:、批量刪除頁眉、頁腳打開 vb 編輯器之后,復(fù)制以下代碼到框里面SubDim myDialog As FileDialog, oDoc As Document, oSec As SectionDim o

2、File As Variant, myRange As RangeOn Error Resume NextSet myDialog = Application.FileDialog(msoFileDialogFilePicker)With myDialog.Filters.Clear.Filters.Add " 所有 Word 文件", "*.doc,*.docx", .AllowMultiSelect = TrueIf .Show = -1 ThenFor Each oFile In .SelectedItemsSet oDoc = Word.Docu

3、ments.Open(FileName:=oFile, Visible:=False)For Each oSec In oDoc.SectionsSet myRange = oSec.Headers(wdHeaderFooterPrimary).Range myRange.Delete ' 刪除頁眉中的內(nèi)容myRange.ParagraphFormat.Borders(wdBorderBottom).LineStyle = wdLineStyleNone ' 段落下邊框線Set myRange = oSec.Footers(wdHeaderFooterPrimary).Rang

4、emyRange.Delete ' 刪除頁腳中的內(nèi)容NextoDoc.Close TrueNextEnd IfEnd WithEnd Sub可以多選批然后點擊運行, 會彈出選擇框, 選取所要刪除頁眉頁腳的文檔, 量炒作。二、批量刪除最后一頁復(fù)制以下代碼到 vb 編輯框,點擊運行即可,可多選Sub DeleteLastPageOfDocs()Dim fd As FileDialogDim aDoc As DocumentDim i As LongDim count As LongSet fd = Application.FileDialog(FileDialogType:=msoFile

5、DialogOpen)With fd.AllowMultiSelect = True.Title = "請選擇要處理的一個或多個 Word 文檔 ".Filters.Add "Word 文檔 ", "*.doc; *.docx", 1If .Show = -1 Thencount = .SelectedItems.countFor Each vrtSelectedItem In .SelectedItemsSet aDoc = Documents.Open(vrtSelectedItem)With ActiveDocument .Bo

6、okmarks("EndOfDoc").Range.Select .Bookmarks("Page").Range.Delete 'Delete the last manual page break if there isn't any text after it For i = ActiveDocument.Paragraphs.count To 1 Step -1If Asc(.Paragraphs(i).Range.Text) = 12 Then .Paragraphs(i).Range.Delete Exit ForEnd IfI

7、f Len(.Paragraphs(i).Range.Text) > 1 ThenExit ForEnd IfNext iEnd WithaDoc.SaveaDoc.CloseNextMsgBox "已處理 " & count & " 個 Word 文檔"End IfEnd WithEnd Sub三、批量提取文件夾內(nèi)文件名稱Sub 提取指定文件夾內(nèi)文件夾名字 ()Dim Fso, FldDim Arr(1 To 999), k%Set Fso = CreateObject("Scripting.FileSystemObje

8、ct")Set Fid = Fso.GetFolder(CreateObject("Shel I.A pplicatio n").BrowseForFolder(0請選 擇文件夾 ", 0, "").Self.Path & "")For Each fd In Fld.SubFoldersk = k + 1Arr(k) = fd.NameNext a2.Resize(k) = Applicatio n.Tra nspose(Arr)End Sub四、批量調(diào)整頁邊距打開vb編輯器,輸入以下代碼Opti on E

9、xplicitSub Example2()'此代碼為指定文件夾中所有選取的WORD文件的進(jìn)行格式設(shè)置Dim MyDialog As FileDialog, vrtSelectedltem As Varia nt. Doc As Docume nt'On Error Resume Next ' 忽略錯誤'定義一個文件夾選取對話框Set MyDialog = Applicatio n.FileDialog(msoFileDialogFilePicker)With MyDialog.Filters.Clear '清除所有文件篩選器中的項目.Filters.Ad

10、d " 所有 WORD文件", "*.doc", 1'增加篩選器的項目為所有 WORD文件.AllowMultiSelect = True '允許多項選擇If .Show = -1 The n '確定Applicati on. Scree nU pdati ng =:FalseFor Each vrtSelectedItem In .SelectedItems '在所有選取項目中循環(huán)Set Doc = Docume nts.Ope n(FileName:=vrtSelectedltem, Visible:=False) W

11、ith DocWith P ageSetup丄 i neNumberi ng.Active = False.Orie ntatio n = wdOrie ntPortrait.TopMargin = Cen timetersToPoi nts(2.2)'頂部頁邊距.BottomMargin = Cen timetersToPoi nts(2.2)'底部頁邊距丄 eftMargin = Cen timetersToPoi nts(2.5)'左部頁邊距.RightMargin = CentimetersToPoints(2.5)'右部頁邊距.Gutter = Cen

12、 timetersToPoi nts(O).HeaderDista nee = Cen timetersToPo in ts(1.5) .FooterDista nee = Cen timetersToPo in ts(1.75) P ageWidth = Cen timetersToPoi nts(21)P ageHeight = Cen timetersToPoi nts(29.7) .FirstPageTray = wdPri nterDefaultBin .OtherPagesTray = wdPri nterDefaultBin .Sectio nStart = wdSecti on

13、N ewPage .OddA ndEve nPagesHeaderFooter = False .Differe ntFirstPageHeaderFooter = False .VerticalAlig nment = wdAlig nVerticalTop .SuppressE ndno tes = False.MirrorMargi ns = False.TwoPages OnOne = False.BookFoldPri nti ng = False.BookFoldRevPri nti ng = False.BookFoldPri ntin gSheets = 1.GutterPos

14、 = wdGutterPosLeft.LayoutMode = wdLayoutModeL in eGrid End WithWith .Conten t.ParagraphFormat丄 eftI ndent = Cen timetersToPoi nts(0)|.RightI ndent = Cen timetersT oPoi nts(O) .SpaceBefore = 0.SpaceBeforeAuto = False.SpaceAfter = 0|.SpaceAfterAuto = False.Lin eSpaci ngRule = wdL in eSpaceExactly.Lin

15、eSpaci ng = 24.Alig nment = wdAlig nParagraphJustify.WidowC on trol = False.KeepWithNext = False.KeepTogether = False.PageBreakBefore = False.NoL in eNumber = False.Hyphe natio n = True.FirstL inelndent = Cen timetersToPoi nts(O).Outl in eLevel = wdOutl in eLevelBodyText.CharacterU nitLeftl nde nt =

16、 0.CharacterU ni tRight In de nt = 0.Character Un itFirstLi nel ndent = 0丄 i neUn itBefore = 0.Li neUn itAfter = 0.AutoAdjustRightl ndent = True.DisableLi neHeightGrid = False.FarEastL in eBreakC on trol = True.Wordwrap = True.Ha ngingPun ctuatio n = True.HalfWidthPu nctuatio nOn TopOfLi ne = False .AddSpaceBetw

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論