4 Replies Latest reply: Sep 19, 2017 3:25 PM by Cecília Fujita Abrahão RSS

    Export to Microsoft Excel button grayed out!

      Hello friends. I have tried to create a button to export a document or anything else to a microsoft excel application, but my botton is always grayed out and i can't do anything to revert that. My co-workers have succeeded, but i have not and i feel ashamed to ask how they did.

       

      this is what i did. New folder object > button > I give it a name > actions > include > external > run macro > edit module >

       

      Sub Exportar_Objetos_Excel

       

      'Setando o Objeto que será exportado

        Set Objetos = ActiveDocument.GetSheetObject("CH01")

      'Definições do arquivo Excel

        Set XLApp = CreateObject("Excel.Application")

        Set XLDoc  = XLApp.Workbooks.Add

        Set XLSheet = XLDoc.Worksheets(1)

        XLApp.Visible = True

      'Selecionando e excluido as bordas de toda a Aba Excel

        XLApp.Cells.Select

           XLApp.ActiveWindow.DisplayGridlines = False

      'Selecionando a Célula A1 e colando o conteúdo do Objeto CH01

        XLApp.Range("A5").Select

      'Para exportar os dados como tabela utilize o CopyTableToClipboard

      '  ActiveDocument.GetSheetObject("CH01").CopyTableToClipboard True

      'Para exportar o gráfico como imagem utilize o CopyBitMapToClipboard  

        ActiveDocument.GetSheetObject("CH01").CopyBitMapToClipboard

        XLSheet.Paste

      'Selecionando a célula A1

        XLSheet.Range("A1").Select

       

      End Sub

       

      I verify, it's ready but when i test it, it says : the ActiveX cannot create the object : 'Excel.Application'

       

      I don't know how to do that neither for a Word document. Help me out please. Thank you all