Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need to write macro for exporting data in excel.

Hi All,

I need to write a macro to export data in excel. Here is my requirement.

1. I ave created 10 bookmarks on different selection.

2. Now I want to export the data sapretly (with respect to bookmark) in excel sheet.

3. All the data should come in one excel but in different sheets (i.e in all the 10 bookmarks data in different 10 shet of same excel).

Your help will be highly appriciated !

Thanks,

D J

3 Replies
Gysbert_Wassenaar

See this discussion for using bookmarks in macro's : http://community.qlik.com/thread/74046

See this blog post for exporting to excel with macro's: http://www.qlikblog.at/971/qliktip-32-exporting-multiple-objects-single-excel-document/


talk is cheap, supply exceeds demand
Not applicable
Author

Hi,

I have tried this but it's not working for me. And while trying to create a excel file I am getting the following error message:

ERROR:-

 

ActiveX component can't create object: 'Excel.Application'

I am using the following code to create excel

CODE:

 

Sub ExcelExpwCaption
'Set the path where the excel will be saved
filePath = "C:\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("CH01")
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

sujeetsingh
Master III
Master III