about sp_OAMethod

  • Hi, I have a big problem to execute some Excel Com methods by sp_OAMethod, anyone would help me?

    below is the code :

    -------

    declare @After varchar(255)

    set @Method='Application.ActiveWorkbook.Sheets("materials").Copy'

    exec @retcode=sp_OAMethod @ExcelObj, @Method,@After= 'Application.ActiveWorkbook.Sheets(1)'

    ----------

    the ErrorCode is"-2147211483"

    Description is "sp_OAMethod's usage..."

    Why?

    Thanks!

  • It's done!

    Code like this 🙂

    -------------------

    declare @before int, @after int, @oSheet1 int, @oSheet2 int

    EXEC @retcode=sp_OAGetProperty @ExcelObj, 'Sheets.Item("sheet1")', @oSheet1 OUTPUT

    EXEC @retcode=sp_OAGetProperty @ExcelObj, 'Sheets.Item("sheet2")', @oSheet2 OUTPUT

    set @Method='Copy'

    exec @retcode=sp_OAMethod @oSheet2, @Method, null, @before=null,@after=@oSheet1

    -------------------------------

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply