Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I export title Caption in Excel?

Hi,

i need to insert Chart/Report Caption Title when I extract to excel.

I see that I can use a macro for that, but when I test the code I'm getting error like

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


I Use this code:


     Sub ExcelExpwCaption

     'Set the path where the excel will be saved

     filePath = "C:\"

     'Create the Excel spreadsheet

     Set excelFile = CreateObject("Excel.Application")

     excelFile.Visible = true

     'Create the WorkBook

     Set WorkBook = excelFile.WorkBooks.Add

     'Create the Sheet

     Set Sheet = WorkBook.WorkSheets(1)

     'Get the chart we want to export

     Set tableToExport = ActiveDocument.GetSheetObject("LB02")

     Set chartProperties = tableToExport.GetProperties

     tableToExport.CopyTableToClipboard true

     'Get the caption

     chartCaption = tableToExport.GetCaption.Name.v

     'MsgBox chartCaption

     'Set the first cell with the caption

     Sheet.Range("A1") = chartCaption

     'Paste the rest of the chart

     Sheet.Paste Sheet.Range("A2")

     excelFile.Visible = true

     'Save the file and quit excel

     WorkBook.SaveAs filePath

     WorkBook.Close

     excelFile.Quit

     'Cleanup

     Set WorkBook = nothing

     Set excelFile = nothing

End Sub

Is there another way to see title in exported file?

Thanks a lot

regards

Francesca

1 Solution

Accepted Solutions
Not applicable
Author

In this string from you macros

chartCaption = tableToExport.GetCaption.Name.v ----> you get title

Sheet.Range("A1") = chartCaption -----> put title into excel file

View solution in original post

8 Replies
Not applicable
Author

Hello. Your script is written is true. Problem in configuring security levels for macros. In the macro editor, adjust the desired level or press Ctrl-Shift-M.

Not applicable
Author

This Code is only for one Report.

I want to Export Caption Title for every report in my dashboards.

How can I do?

Not applicable
Author

This is not a trivial task. For each report, write a separate piece of code, or use a loop to retrieve all names and ID reports. It's not easy. In this I will not be able to help you.

jonathandienst
Partner - Champion III
Partner - Champion III

If you are running this on a server, then it is possible (even likely) that Excel is not installed on the server. that call requires that Excel is installed and accessible to the user (or service account) running the script.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks a lot!

How can i see report name when i export to excel?

Not applicable
Author

What do you mean? For example "LB02".

Not applicable
Author

LB02 is che object ID.  I need to see Title of the object when export to excel

Not applicable
Author

In this string from you macros

chartCaption = tableToExport.GetCaption.Name.v ----> you get title

Sheet.Range("A1") = chartCaption -----> put title into excel file