||-- ADDENDUM -- Although the code I posted two days ago worked well on a test case, the code did not work on the actual files I needed to modify. The test case was a folder with a few small and simple MXD files with features from only one data source, and no additional text, north arrows, etc. The files I actually needed to edit were much more complex, had multiple data sources, text, north arrows, scale bars, etc. etc. Still, I canít think of why the code worked on the first group of files but not the second.
When I run the code on the second group of files, the first file in the folder opens as "Untitled," and then a "Save As..." window opens. The code grinds to a halt and I get an error -- the errors I've gotten are both "The server threw an exception" and "Method 'SaveDocument' of object 'IApplication' failed".
I've done a little troubleshooting to learn the following:
- neither set of files is read-only
- the problem is not a file-name or file-path-name issue
- I can't find any differences in their map properties (File --> Map properties...)
- the problem is not related to the location of the VBA code (in the Word document) relative to the files I'm trying to edit
- the problem is not related to the code that modifies the MXD (rather, it's the looping code I posted that doesn't work)
I'm completely mystified. I'd be very grateful if someone could help me figure out why my two sets of files behave differently using the same code.