روزاریو تعداد زیادی سند دارد (حدود 44000 مورد) که هر کدام شامل یک تصویر گرافیکی در سربرگ است. او به دنبال راهی برای حذف تمام آن گرافیک ها بدون نیاز به باز کردن و اصلاح هر سند به صورت دستی است.
خوشبختانه با ایجاد یک ماکرو می توان این کار را انجام داد. تنها کاری که باید انجام دهید این است که تمام اسناد را در یک پوشه قرار دهید و سپس از ماکرو برای جستجو در پوشه، باز کردن هر سند، حذف گرافیک و ذخیره هر سند استفاده کنید. این کار را می توان با یک ماکرو مانند زیر انجام داد:
Sub StripGraphics() Dim oShape As Shape Dim oIShape As InlineShape Dim I As Integer Dim J As Integer With Application.FileSearch .LookIn = "C:MyStuff"where to search .SearchSubFolders = Truesearch the subfolders .FileName = "*.docx"file pattern to matchif more than one match, execute the following code If .Execute() > 0 Then MsgBox "Found " & .FoundFiles.Count & " file(s)."for each file you find, run this loop For I = 1 To .FoundFiles.Countopen the file based on its index position Documents.Open FileName:=.FoundFiles(I)document is now active, check all sections For J = 1 To ActiveDocument.Sections.Count With ActiveDocument.Sections(J).Headers(wdHeaderFooterPrimary)remove floating graphics from header If .Shapes.Count > 0 Then For Each oShape In .Shapes oShape.Delete Next oShape End Ifremove inline graphics from header If .Range.InlineShapes.Count > 0 Then For Each oIShape In .Range.InlineShapes oIShape.Delete Next oIShape End If End With With ActiveDocument.Sections(J).Headers(wdHeaderFooterFirstPage)remove floating graphics from header If .Shapes.Count > 0 Then For Each oShape In .Shapes oShape.Delete Next oShape End Ifremove inline graphics from header If .Range.InlineShapes.Count > 0 Then For Each oIShape In .Range.InlineShapes oIShape.Delete Next oIShape End If End With Next Jsave and close the current document ActiveDocument.Close wdSaveChanges Next I Else MsgBox "No files found." End If End With End Sub
این ماکرو این فرض را ایجاد می کند که می خواهید تمام گرافیک ها (اعم از شناور و درون خطی) را در هدر حذف کنید. اینها حذف می شوند و هر فایل دوباره ذخیره می شود. ماکرو روی هیچ گرافیک دیگری در سند تأثیر نمی گذارد.
باید توجه داشته باشید که این ماکرو خاص فایل هایی را که از پسوند DOCX استفاده می کنند بررسی می کند. اگر اسنادی دارید که از پسوندهای مختلفی استفاده می کنند (مانند DOCM یا DOC قدیمی)، باید چندین بار ماکرو را اجرا کنید. بین هر اجرا، خطی را که الگوی پسوند فایل را تعیین می کند، تغییر دهید. (در انتهای این خط یک نظر وجود دارد که می گوید: "الگوی فایل مطابقت دارد".)