PDA

View Full Version : Batch delete Data/header source file



alundra828
06-11-2015, 02:25 AM
Hello all! I'm currently having an issue with one of my scripts that batch edits documents. The problem is not with the script itself, it's something I have overlooked, and have no idea how to sort!

The script is batch editing documents with mergedata in it. Meaning, that when my script opens the file, and starts to make the amendments, it is asking for the .hed file, which you can remove manually, but if you're editing hundreds of documents it causes it to hang, and time out/crash. And this process is supposed to be as automated as it can be. Having to manually remove the data/header source file is a pain that sort of doesn't make this viable any more.

I was wondering if any of you could wizard up some code to automatically remove the data/header source file from all .doc files in a definable folder?

Thanks in advance!

gmayor
06-11-2015, 06:40 AM
You could use the following Function as a custom process with http://www.gmayor.com/document_batch_processes.htm which will handle the folders.


Function RemoveData(oDoc As Document) As Boolean
On Error GoTo err_Handler
oDoc.MailMerge.MainDocumentType = wdNotAMergeDocument
RemoveData = True
lbl_Exit:
Exit Function
err_Handler:
RemoveData = False
Resume lbl_Exit
End Function

alundra828
06-11-2015, 09:03 AM
Hey Gmayor, not having any luck using that app i'm afraid! any function or sub i can parse through within my script?

gmayor
06-11-2015, 08:40 PM
In what way didn't it work? It opens all the documents in a folder and sends the command


ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
(oDoc being the active document) which removes the header information. You could include this line in your own macro, but if the batch process doesn't work for you then there is some other issue involved.