Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Deleting a Macro from a VBS Script

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim - 13 Feb 2006 20:49 GMT
I have a large number of documents that have a digitally signed macro
in them.   I am attempting to mass-delete this macro from the
documents.  I created a VB Script which searches the given directory,
instantiates a Word Object and opens each file one at a time.

How do I delete a macro if I have a Word.Document Object and I know the
name of the macro?

My current VBCode is attached.

Thanks in advance for any help.

-Jim

-------------------Begin Included VB Script-----------------
'Set Type of Files To Act Upon
DocumentType="Microsoft Word Document"

'Generate Objects for Filesystem, Folder, and Files within the current
folder
Set FileSysObj = CreateObject("Scripting.FileSystemObject")
Set FileSysFolder =
FileSysObj.GetFolder(FileSysObj.GetAbsolutePathName("."))
Set FileSysFiles = FileSysFolder.Files

Set Word = CreateObject("Word.Application")
Word.Visible = True
'Loop through each File In the Folder
For Each ObjFile in FileSysFiles
 If (objFile.Type = DocumentType) Then

    Doc_Name = FileSysFolder & "\" & objFile.Name
    Word.Documents.Open(Doc_Name)

   'INSERT CODE TO DELETE MACRO AutoOpen

    Word.Documents(Doc_Name).Save()
    Word.Documents(Doc_Name).Close()
 End If
Next

Word.Quit
--------------------End Included VB Script
------------------------------------
Charles Kenyon - 13 Feb 2006 21:54 GMT
You need to know the name of the macro and the module to be very effective.
Otherwise, you are going to have to cycle through them with your code. Note
that even if you remove the macro, the document will trigger macro warnings
from security.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

>I have a large number of documents that have a digitally signed macro
> in them.   I am attempting to mass-delete this macro from the
[quoted text clipped - 40 lines]
> --------------------End Included VB Script
> ------------------------------------
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.