/ * Description: NEED Office 2000 Parameter Description: ---------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------- @TranStype conversion type 0 - GB-> BIG5 1 - BIG5-> GB @sintext text @SoutText Return Text ---------- ----------------------------------------------- * /
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 @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 outness @errhandler! = 0 begin exec sp_oageterrorinfo @Serection return end --- EXEC @ERRHANDLER = SP_OADESTROY @