3 Replies Latest reply: Jul 14, 2012 5:09 PM by Jose Tos RSS

    macro export

    Gerhard Laubscher

      Hi there,

       

      I am creating buttons, which exports different tables to excel (which I then use daily to update a report).

       

      It works fine, except for the formatting in excel - it is different than when I use the "XL" button on the table itself. Normally I then use the exported table and paste into my daily report, and Is elect "match destination formatting" in excel - and I am done.

       

      When I use the button (which runs a macro), the exported table is in a weird format and when I paste it in excel I do not get the normal option where I can "match to destination" - and it messes up my report's format.

       

      How can I edit the macro to use the exact same export rules as per my User Preferences in QV:

       

      sub exportPerformanceTabletoExcel

       

        set obj = ActiveDocument.GetSheetObject( "CH187" )

        set XLApp = CreateObject("Excel.Application")

              XLApp.Visible = True

        set XLDoc = XLApp.Workbooks.Add

        set XLSheet = XLDoc.Worksheets(1)


        obj.CopyTableToClipboard true

        XLSheet.Paste


      end sub

       

      Thanks,

       

      Gerhard

        • Re: macro export
          Gerhard Laubscher

          Also, is it possible to send the below two tables to the same worksheet in excel:

           

          sub exportPerformanceTabletoExcel

           

            set obj = ActiveDocument.GetSheetObject( "CH187" )

            set XLApp = CreateObject("Excel.Application")

                  XLApp.Visible = True

            set XLDoc = XLApp.Workbooks.Add

            set XLSheet = XLDoc.Worksheets(1)


            obj.CopyTableToClipboard true

            XLSheet.Paste
           
            set obj = ActiveDocument.GetSheetObject( "CH189" )

            set XLApp = CreateObject("Excel.Application")

                  XLApp.Visible = True

            set XLDoc = XLApp.Workbooks.Add

            set XLSheet = XLDoc.Worksheets(1)


            obj.CopyTableToClipboard true

            XLSheet.Paste


          end sub