D
Devhead
i need to open a Word Document from sql server database, make updates to the
document, then save as READ-ONLY. Basically, this will be a view of the
document that user cannot change. updates to the document are done by
reading field data from the database into the document.
i can read the blob doc to file on local PC but i have noticed some speed
losses viewing the document READ-ONLY vs viewing without this condition.
please see code in question below. it seems like a waste of run time to have
to Save the Document, Close it, then Open it Read-Only but that's the only
way i know how unless someone else out there has a faster way. please
respond if so. thanks.
if ((bool) oReadOnly)
{
oDoc.SaveAs(ref oFilePath, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
oDoc = oWord.Documents.Open(ref oFilePath, ref oMissing, ref oReadOnly, ref
oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing);
File.SetAttributes((string) oFilePath,System.IO.FileAttributes.ReadOnly);
}
else
{
oDoc.SaveAs(ref oFilePath, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
}
document, then save as READ-ONLY. Basically, this will be a view of the
document that user cannot change. updates to the document are done by
reading field data from the database into the document.
i can read the blob doc to file on local PC but i have noticed some speed
losses viewing the document READ-ONLY vs viewing without this condition.
please see code in question below. it seems like a waste of run time to have
to Save the Document, Close it, then Open it Read-Only but that's the only
way i know how unless someone else out there has a faster way. please
respond if so. thanks.
if ((bool) oReadOnly)
{
oDoc.SaveAs(ref oFilePath, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
oDoc.Close(ref oMissing, ref oMissing, ref oMissing);
oDoc = oWord.Documents.Open(ref oFilePath, ref oMissing, ref oReadOnly, ref
oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing);
File.SetAttributes((string) oFilePath,System.IO.FileAttributes.ReadOnly);
}
else
{
oDoc.SaveAs(ref oFilePath, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref
oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
}