Command line script to search folder and remove Word macros
I have 2700 Word documents in which the AutoOpen macro fails. I do not want to have to open each document by hand and manually delete the AutoOpen macro.
So, I need to create a script that can be run from the command line to open Word documents from a folder and delete the AutoOpen macro from each document.
I have the code below so far, but one problem is opening the document fires the AutoOpen. Can this be prevented? I've seen the switch /m to stop the macros from running on open, but it doesn't work in the script on the .Open statement.
The second problem is: Are there functions that can be used in the script to delete the AutoOpen macro?
Thanks for any help you can offer.
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set FSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
For Each File In Folder.Files
Set objDoc = objWord.Documents.Open(File.Path /m)
Back to top
Posted: Jan 25, 08, 11:08 techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Location: East Coast, West Coast? I know it's one of them.
We don't offer MS word macro support here, sorry.
If someone comes along with an answer though, that's of course fine.
Back to top
All times are GMT - 8 Hours