Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Export Macro to Excel

Hello,

I have this macro that exports the table in one excel's file, i want that excel's file Name keep the last value of one table's field.

For example: Field A: 2010;2011;2012 the name will be 2012.

    

Sub exportExel

     dim ls_date

set ExcelSheetApp  = CreateObject("Excel.Application")

ExcelSheetApp.Visible = false

     set ExcelWB= ExcelSheetApp.Workbooks.Add

     ExcelWB.Sheets(1).name = "Storico"

     set XLSheet = ExcelWB.Worksheets(1)

     set QVData = ActiveDocument.GetSheetObject("CH01")

set XLSheet = ExcelWB.Worksheets(1)

QVData.CopyTableToClipboard true

     XLSheet.Paste XLSheet.Range("A1")

ExcelWB.SaveAs "C:\Users\ut0854\Desktop\Qlik Omicron\Diagnostico\Storico\NAME OF FILE.xlsx", 51

ExcelWB.Close

ExcelSheetApp.Application.Quit

End Sub

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

This is from the API Guide:

set v = ActiveDocument.Variables("Variable1")

msgbox(v.GetContent.String)

View solution in original post

4 Replies
m_woolf
Master II
Master II

You might store the Max of field A in a variable and use the variable value in the macro to get the filename.

Anonymous
Not applicable
Author

Ok thanks.

But after i have created  the variable

varmax = Max(Date(DataComp1,'DD/MM/YYYY'))

How can i use the value of this variable in the macro?

m_woolf
Master II
Master II

This is from the API Guide:

set v = ActiveDocument.Variables("Variable1")

msgbox(v.GetContent.String)

Anonymous
Not applicable
Author

thanks a lot

for your kindness