萬盛學電腦網

 萬盛學電腦網 >> WORD教程 >> WORD使用技巧 >> Word搜索指定位置的所有DOC文檔

Word搜索指定位置的所有DOC文檔

   Dim Adoc As String, PsDoc As Document

  On Error Resume Next

  ChDrive "C" ‘設置當前驅動器盤符

  ChDir "C:Documents and SettingsMy DocumentsTemp" ‘進入指定目錄

  Adoc = Dir("*.doc")

  Application.ScreenUpdating = False

  Do While Adoc <> "" ‘如果是文件夾,或者沒有此文件,則會返回""

  ‘ MsgBox Adoc

  Set PsDoc = Documents.Open(Adoc) ‘打開指定文檔

  PsDoc.Protect Type:=wdAllowOnlyFormFields, Password:="Password"

  PsDoc.Close True

  Adoc = Dir()

  Loop

  Application.ScreenUpdating = True

  使用的時候,請將如上的代碼放在宏中來使用。

copyright © 萬盛學電腦網 all rights reserved