Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies. Only from Platform Scholar.
Public Sub Test() Dim FilePath As String = "C:\Change to Your Path\Test Doc.docx" ' Create a new instance of word and open some document in it Dim WordInstance As New Microsoft.Office.Interop.Word.Application Dim Document As Microsoft.Office.Interop.Word.Document = WordInstance.Documents.Open(FilePath) ' Now try to create a readonly stream (to send a copy of our ' changes back to the server) Dim fStream As FileStream = Nothing Try fStream = New FileStream(Me._FilePath, FileMode.Open, FileAccess.Read, FileShare.Read) Catch ex As Exception MessageBox.Show("Error: " & ex.Message) Finally If fStream IsNot Nothing Then fStream.Close() fStream = Nothing End If End Try WordInstance.Quit() End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.