*
Description:
---需要安裝Office 2000
統杅佽隴:
-------------------------------------------------------
@TransType 轉換類型
0 -- 簡體轉繁體
1 -- 繁體轉簡體
@sInText 待轉換的字串
@sOutText 轉換後的字串
-------------------------------------------------------
*/
ALTER Proc spConverter @TransType tinyint,@sInText Nvarchar(4000),@sOutText Nvarchar(4000)OUTPUT
AS DECLARE @WordApplication int
DECLARE @ErrHandler int
DECLARE @Document int
DECLARE @Selection int
DECLARE @Message NVARCHAR(4000)
DECLARE @src varchar(255), @desc varchar(255)
--Create Word instance
EXEC @ErrHandler = sp_OACreate 'Word.Application', @WordApplication OUT
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @WordApplication, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@ErrHandler), Source=@src, Description=@desc
RETURN
END
---// create instance end
--Create a word document instance
EXEC @ErrHandler = sp_OACreate 'Word.Document', @Document OUT
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Document, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@ErrHandler), Source=@src, Description=@desc
RETURN
END
--//
---
EXEC @ErrHandler = sp_OAGetProperty @Document, 'Application.Selection', @Selection OUT
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Document
RETURN
END
EXEC @ErrHandler = sp_OASetProperty @Selection, 'Text', @sInText
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Selection
RETURN
END
EXEC @ErrHandler = sp_OAMethod @Selection, 'Range.TCSCConverter',NULL,@TransType,1,1
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Selection
RETURN
END
EXEC @ErrHandler = sp_OAGetProperty @Selection, 'Text', @sOutText OUT
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Selection
RETURN
END
---
EXEC @ErrHandler = sp_OADestroy @WordApplication
IF @Errhandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @WordApplication
RETURN
END
---
EXEC @ErrHandler = sp_OADestroy @Document
IF @Errhandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Document
RETURN
END
EXEC sp_OAStop
RETURN
Description:
---需要安裝Office 2000
統杅佽隴:
-------------------------------------------------------
@TransType 轉換類型
0 -- 簡體轉繁體
1 -- 繁體轉簡體
@sInText 待轉換的字串
@sOutText 轉換後的字串
-------------------------------------------------------
*/
ALTER Proc spConverter @TransType tinyint,@sInText Nvarchar(4000),@sOutText Nvarchar(4000)OUTPUT
AS DECLARE @WordApplication int
DECLARE @ErrHandler int
DECLARE @Document int
DECLARE @Selection int
DECLARE @Message NVARCHAR(4000)
DECLARE @src varchar(255), @desc varchar(255)
--Create Word instance
EXEC @ErrHandler = sp_OACreate 'Word.Application', @WordApplication OUT
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @WordApplication, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@ErrHandler), Source=@src, Description=@desc
RETURN
END
---// create instance end
--Create a word document instance
EXEC @ErrHandler = sp_OACreate 'Word.Document', @Document OUT
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Document, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@ErrHandler), Source=@src, Description=@desc
RETURN
END
--//
---
EXEC @ErrHandler = sp_OAGetProperty @Document, 'Application.Selection', @Selection OUT
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Document
RETURN
END
EXEC @ErrHandler = sp_OASetProperty @Selection, 'Text', @sInText
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Selection
RETURN
END
EXEC @ErrHandler = sp_OAMethod @Selection, 'Range.TCSCConverter',NULL,@TransType,1,1
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Selection
RETURN
END
EXEC @ErrHandler = sp_OAGetProperty @Selection, 'Text', @sOutText OUT
IF @ErrHandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Selection
RETURN
END
---
EXEC @ErrHandler = sp_OADestroy @WordApplication
IF @Errhandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @WordApplication
RETURN
END
---
EXEC @ErrHandler = sp_OADestroy @Document
IF @Errhandler != 0
BEGIN
EXEC sp_OAGetErrorInfo @Document
RETURN
END
EXEC sp_OAStop
RETURN
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货