Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
Thanks, but this macro works with QV 8.5 ?
Please I need to add record in a xls file not overwrite the file ..
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