Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have straight table chart with 50 columns out of which I want to export to excel only 10 columns.
Thanks in advance.
You can simply make a copy of your straight table and remove the 40 columns you don't need and then export that table directly.
This is how you can export the Straight Table:
Set tb = ActiveDocument.GetSheetObject("TB01")
tb.ServerSideExportEx "C:\test.xls" , ";" , 5
hidden the renaming columns and export 10 columns
Another way to do this is create variable,for example, "vHideColumns" and conditions for show 40 columns. (vHideCoulumns = true()). After that, create three actions for button "Export to excel" .
1. Change variable vHideCoulumns = true()
2. Export to excel via macros (vbscript)
3. Change variable vHideCoulumns = false()
Thanks for the reply.
The scenario is not that simple as it looks.
The hidden columns are used in some logical calculations, when i hide those columns based on some variable conditionally, the calculated values are going for toss. So hiding column is not working, i tried already.
Somehow, i need to chose the required columns from straight table using macro and export the same.
I think, you can try to export in Excel via this macros(copy to excel without using system clipboard,gradually at each cell😞
Sub ExcelAppend (PFM)
SET objExcelApp = CREATEOBJECT("Excel.Application")
objExcelApp.DefaultSaveFormat = xlWorkbookNormal
objExcelApp.Workbooks.Open Template
SET objExcelSheet = objExcelApp.Worksheets(1)
SET objObjectFrom = ActiveDocument.GetSheetObject("TB01")
MaxColumn = objObjectFrom.GetColumnCount
MaxRow = objObjectFrom.GetRowCount
FOR intObjectRow = 1 To MaxRow - 1
FOR intObjectColumn = 0 To MaxColumn - 1
SET objCell = objObjectFrom.GetCell(intObjectRow, intObjectColumn)
objExcelSheet.Cells(intObjectRow+20,intObjectColumn+2) = objCell.Text
NEXT
objExcelSheet.Cells(intObjectRow+20,1).Value = intObjectRow
NEXT
objExcelApp.DisplayAlerts = False
objExcelSheet.SaveAs DirPFM
objExcelApp.Application.Quit
SET objExcelSheet = NOTHING
SET objExcelApp = NOTHING
END SUB