Create Procedure [dbo].[sp_Converter](@TransType tinyint,@sInText nVarchar(4000),@sOutText nVarchar(4000) OUTPUT) 
AS
Begin
	Declare @App int		
	Declare @Doc int		
	Declare @Err int		
	Declare @Selection int	

	Exec @Err = sp_OACreate 'Word.Application', @App OUT
	If @err<>0 goto lb_err
	Exec @Err = sp_OACreate 'Word.Document', @Doc OUT
	If @err<>0 goto lb_err
	Exec @Err = sp_OAGetProperty @Doc, 'Application.Selection', @Selection OUT
	If @err<>0 goto lb_err 
	Exec @Err = sp_OASetProperty @Selection, 'Text', @sInText
	If @err<>0 goto lb_err
	Exec @Err = sp_OAMethod @Selection, 'Range.TCSCConverter',NULL,@TransType,1,1
	If @err<>0 goto lb_err
	Exec @Err = sp_OAGetProperty @Selection, 'Text', @sOutText OUT
	If @err<>0 goto lb_err
	Exec @Err = sp_OASetProperty @Doc, 'Saved', 'True'
	If @err<>0 goto lb_err
	EXEC @Err = sp_OAMethod @App,'Quit'
	If @err<>0 goto lb_err
	Exec @Err = sp_OADestroy @App
	If @err<>0 goto lb_err
	Exec @Err = sp_OADestroy @Doc
	If @err<>0 goto lb_err
	Exec sp_OAStop
	Return
	lb_err:
	return null
End
/*
提示消息筛选器显示应用程序正在使用中
解决办法  
1.在命令行中输入:dcomcnfg,会显示出组件服务管理器 
2.打开组件服务->计算机->我的电脑->DCOM 配置,找到Microsoft Word文档,单击右键,选择属性
3.在属性对话框中单击标识选项卡,选择交互式用户
*/