We have old Word templates that were originally written for Word 97. For each new version, we've updated the templates. Now we'll go from Word 2003 to Word 2010, and of course there are problems.
The template contains the following code:
Private Sub Document_Open()
On Error Resume Next
If ActiveDocument.Type = wdTypeDocument Then
' Update the document from database'
End If
End Sub
The problem is that the ActiveDocument gives the error
This command is not available Because no document is open
The documents is open with script on the intranet:
<a href="javascript:opendokument('P:\\01\\2-010-01.doc')">012-010-01</a>
<SCRIPT language=javascript>
function opendokument(dokument){
var objAppl;;
try{
objAppl = GetObject("","Word.Application");
objAppl.Documents.open(dokument);
}
catch(exception){
objAppl = new ActiveXObject("Word.Application");
objAppl.Visible = true;
objAppl.Documents.open(dokument);
}
objAppl = null;
}
</script>
If I run the script from my local computer or open the document via Windows, I don't get the error