Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Write in xls file

Hi,

I need to know how can I write from a input fiel or input box to a .xls file. Please have an example to send me?

Thank you very much.

Regards.

Slash

3 Replies
amars
Specialist
Specialist

Hi Slash,

You can write a macro like this one to export a variable to excel


function ExportToExcel(strFileName)

File = "C:\" & strFileName & ".xlsx"
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(file) Then
filesys.DeleteFile file
End If

set XLApp = CreateObject("Excel.Application")
XLApp.Visible = FALSE
set XLDoc = XLApp.Workbooks.Add

XLDoc.Sheets(1).name = "Report"
set XLSheet = XLDoc.Worksheets(1)

strValue1 = getvariable("Value1")

XLDoc.Sheets(1).Cells(2,2).Value = strValue1

XLDoc.SaveAs "C:\" & strFileName & ".xls"

XLApp.Visible = False
XLApp.Quit
Set XLApp = Nothing

End function


function getVariable(varName)
set v = ActiveDocument.Variables(varName)
getVariable = v.GetContent.String
end function

Hope this helps

Not applicable
Author

Thanks, but this macro works with QV 8.5 ?

Please I need to add record in a xls file not overwrite the file ..

Not applicable
Author

Please I'm not able to link the API to a button. Please Could to attach a qvw file in this post?

Thank you very much

Regards,

Slash