Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How toexport a single Chart from QLV to Excel

Good morning everyone!

I'm a new user of VB and it's the first time I write a macro in QLV. I have (as you will see the attachment) a chart, that I would like to export in an excel file. When used, the macro must to export the chart and to update the already existing file rather than delete it and create a new one. That's what I have done so far:

sub Excel

    nomefile = "C:\E_APPOGGIO\PROVAPROVA.xlsx"

   

   

    set FSO = CreateObject("Scripting.FileSystemObject")

    If FSO.FileExists(nomefile) = True Then

        FSO.DeleteFile nomefile

    End If

    Set FSO = Nothing

  set XLApp = CreateObject("Excel.Application")    'since a few days, though, I could not run this macro anymore as it gives me                                                                                      an error on this line when I debug

  XLapp.Visible = true

  set XLDOC = XLApp.Workbooks.Add

  XLDoc.Sheets(1).name = "Export"

  set XLSheet = XLDoc.Worksheets(1)

  set myTable = ActiveDocument.GetSheetObject("CH01")

  set XLSheet = XLDoc.Worksheets(1)

  Mytable.CopyTableToClipboard true

  XLSheet.Paste XLSheet.Range("A1")

  XLSheet.Cells.Entirerow.AutoFit

  XLSheet.saveas nomefile

  set XLSheet = nothing

  XLDOC.close

  set XLDOC = nothing

  XLApp.quit

  Set XLApp = nothing

end sub

I hope I have been enough clear and that someone could help me!

Many thanks!!

5 Replies
manojkulkarni
Partner - Specialist II
Partner - Specialist II

check this link, might solve your issue.

Qlikview to excel export macro

manojkulkarni
Partner - Specialist II
Partner - Specialist II

Not applicable
Author

I have already seen this post and I have tried to use it for my case, but I dont' think it's what I need. 1. I don't have any other data on the excel sheet where I want to export 2. I need also the headers of the chart I need to export

Not applicable
Author

Sorry to bother you Manoj K but you are proposing me data that I have already found in the web! It's 2 days I'm looking for a piece of code that could suit me. The only solution I always find to my problem is the application.displayalerts=false and True.

They don't solve my problem! as the message ok, doesn't appear, but a new excel file is created! I need to overwrite my PROVAPROVA file!

Greg_Hood
Employee
Employee

You can try the following syntax, which uses the built in API to export the file in BIFF format.  It is the older xls format, but might help you.   It doesn't rename the standard "sheet1" name though, so if that is important this won't help you.   Make sure that your macro security settings allow the required permissions to access system resources.

sub SendToBiff

set obj = ActiveDocument.GetSheetObject("CH01")

obj.ExportBiff "C:\test.xls"

end sub