Function Open(ByVal sourcePath)
	MsgBox Me.DocumentPassword
	Open = False
	Me.Word.AutomationSecurity = Me.AutomationSecurity
	On Error Resume Next
? Начало фрагмента A
	Set Me.Document = Me.Word.Documents.Open(sourcePath, _
		False, True, False, Me.DocumentPassword, vbNullString, _
		True, vbNullString, vbNullString, Me.OpenFormat, _
		Me.TextEncoding, False, Me.RecoverOnOpen)
? Конец фрагмента A
	Me.Word.AutomationSecurity = Me.AutomationSecurity
	If Err.Number <> 0 Then
		Me.ErrorNumber = Err.Number: Me.ErrorInfo = Err.Description
		Set Me.Document = Nothing
		Exit Function
	End If
	On Error Goto 0
	Open = True
End Function

Поделитесь материалом с коллегами и друзьями