Problems opening network file from script.
I have a simple script to open a file from the network and import master pages using portions of Russ Ward and Klaus Daube's code:
function ImportMasterPages(doc)
{
var sFullPath = "\\\\Network Name\\Document_Template.fm"
var Doc_Template = SimpleOpen(sFullPath, "");
//If we successfully opened the file, let's report it.
if(Doc_Template.ObjectValid() == true)
{
// alert("Successfully opened the file:\n\n" + TCTO_Template.Name);
}
//Otherwise, report the failure.
else
{
alert("Couldn't open the file! Check to see if it is an FM document " +
"and if somebody is already using it. The selected path was:\n\n" + sFullPath);
}
Doc_Template.ShowAll = true;
var formatFlags = Constants.FF_UFF_PAGE;
doc.SimpleImportFormats (Doc_Template, formatFlags);
Doc_Template.Close(Constants.FF_CLOSE_MODIFIED)
return;
} // -- end ImportMasterPages
Usually it works. Sometimes it gives us the "Could not open file ..." error. There doesn't seem to be a locking handle when it fails.
I tried deleting and replacing the template on the network and that usually fixes it for a while.
I'm going to try changing "==" to "===" on the Objectvalide line, but does anybody see anything else that might cause this?
