Good day All
I have a macro that has been working satisfactorily for some many months on a wide variety of Word files. Early in the process it is required to save the active document in a newly created “archive” folder as a safety precaution. The line of code that saves the file is:
ActiveDocument.SaveAs FileName:=strPath & "archive" & strName, _ FileFormat:=wdFormatDocument
One particular file, when being processed raises a VBA error message at this point (Error 5180, indicating that Word cannot open a particular template). Irrespective of the warning, the file is saved. The template in question is not identified in the Word “Tools > Templates and Add-ins . . .” pull-down menu. However, it is identified as a Reference in the Project Explorer of VBA. It should be noted that on opening the original file, the user is cautioned that the file contains macros. It used to but doesn’t any more.
When working in Word and saving the file as a new document (File > Save As) with a new name, no alerts are raised, and the offending reference is purged; also on subsequent instances of opening the new file there is no caution about macros.
It is necesssary to remove the possibility of this error message appearing but I am hesitant to insert an “On Error Resume Next” statement at this point, preferring to interrogate for unused references and purge them.
I can’t figure out how to use VBA to identify which references exist and then delete those which are unexpected. Any help wil be greatly appreciated.