在窗口中打开二进制列中的Word文档用的以下代码,想要实现打开的Word文档时受保护的,不允许修改,这样写有问题么?
If Tables("数据字典").Current Is Nothing Then
Return
End If
Dim dr As DataRow = Tables("数据字典").Current.DataRow
Dim fl As String = ProjectPath & dr("_Identify") & ".doc"
If dr.SQLLoadFile("文件",fl) Then '如果提取文件成功
Dim Proc As New Process '打开文件
Proc.File = fl
Proc.Start()
axWebBrowser = Nothing
Do Until axWebBrowser IsNot Nothing
Application.DoEvents
Loop
Dim Doc As object = axWebBrowser.Gettype().InvokeMember("Document", System.Reflection.BindingFlags.GetProperty, Nothing, axWebBrowser, Nothing)
Dim app As object = axWebBrowser.Gettype().InvokeMember("Application", System.Reflection.BindingFlags.GetProperty, Nothing, Doc, Nothing)
doc.Protect (Password:="", NoReset:=False, Type:= _
MsWord.WdProtectionType.wdAllowOnlyReading, UseIRM:=False, EnforceStyleLock:=False)
Else
Messagebox.Show("文件提取失败,可能并不存在文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If