[Office VBA] Sub 刪除文件中所有圖片

底下是個將所有 WORD 檔裡的圖片一次刪除的 VBA ,我也是不知在那看到的,有人知道出處再提醒我一下,我有空再來改成只刪某種類型或是大小的圖片,應該會更實用一點。


Sub 刪除文件中所有圖片()
'
' 範例:刪除文件中所有圖片
'
'
Application.ScreenUpdating = False

Selection.HomeKey Unit:=wdStory

Selection.Find.ClearFormatting
With Selection.Find
.Text = "^g"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

While Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Wend

Application.ScreenRefresh

Application.ScreenUpdating = True

End Sub

0 Comments:

 
© 2008 Blogger Template Layout Design by [ Fanchie AirHead ]