Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I am having two pie chart for this i need a common send to excel button how can i achieve this, since my client said he don't want separate send to excel for the each of the chart , he need common button of XL and when they hit it should pull the two pic chart data to excel .
you need to have macro to do this
Hi,
Below code helps to move the charts to excel. you need to call this on button trigger.
Sub ExcelExpwCaption
'Set the path where the excel will be saved
filePath = "C:\Users\nm36505\Desktop\SD QV\test.xls"
'Create the Excel spreadsheet
Set excelFile = CreateObject("Excel.Application")
excelFile.Visible = true
'Create the WorkBook
Set curWorkBook = excelFile.WorkBooks.Add
'Create the Sheet
Set curSheet = curWorkBook.WorkSheets(1)
'Get the chart we want to export
Set tableToExport = ActiveDocument.GetSheetObject("CH82")
Set chartProperties = tableToExport.GetProperties
tableToExport.CopyTableToClipboard true
'Get the caption
chartCaption = tableToExport.GetCaption.Name.v
'MsgBox chartCaption
'Set the first cell with the caption
curSheet.Range("A1") = chartCaption
'Paste the rest of the chart
curSheet.Paste curSheet.Range("A2")
excelFile.Visible = true
'Save the file and quit excel
curWorkBook.SaveAs filePath
curWorkBook.Close
excelFile.Quit
'Cleanup
Set curWorkBook = nothing
Set excelFile = nothing
End Sub
Note: Macro will not work in Ajax mode.