Listing 1: Example to Automate a Word Method Create Procedure sp_OpenWordIfCoProcAvailable As Declare @Object int, @hr int, @RetVal int Exec @hr = sp_OACreate 'Word.Application', @Object OUTPUT If @hr <> 0 BEGIN Exec sp_DisplayOAErrorInfo @Object, @hr Return 0 END Exec @hr = sp_OAGetProperty @Object, 'MathCoProcessorAvailable', @RetVal If @hr=0 BEGIN Exec @hr = sp_OAMethod @Object, 'Quit', 0 Exec @hr = sp_OADestroy @Object Return 0 END Exec @hr = sp_OAMethod @Object, 'Activate' Return @Object