Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello!
I have a QlikView document that contains a macro that exports a table to Excel. When the application is first opened on the day, when you reload the document, the macro module opens and does nothing else. I enclose the macro, what is the problem with the macro? Why doen't run it immediately when I open QlikView?
Thanks!!
Systems Access Its OK
Sub Export
filePath = "C:\Users\Administrador\Sales.xlsx"
Set excelFile = CreateObject("Excel.Application")
excelFile.Visible = false
Set curWorkBook = excelFile.WorkBooks.Add
Set curSheet = curWorkBook.WorkSheets(1)
Set tableToExport = ActiveDocument.GetSheetObject("TB04")
Set chartProperties = tableToExport.GetProperties
tableToExport.CopyTableToClipboard true
chartCaption = tableToExport.GetCaption.Name.v
curSheet.Range("A1") = chartCaption
curSheet.Paste curSheet.Range("A1")
excelFile.Visible = false
excelFile.DisplayAlerts = False
excelFile.Visible = false
curWorkBook.SaveAs filePath
curWorkBook.Close
excelFile.Quit
Set curWorkBook = nothing
Set excelFile = nothing
End Sub
The fact the Edit Module is opening is indicating some sort of syntax issue in your code. Cannot really debug it for you, what most folks use are msgbox statements to figure out what line is actually causing the issue. There is no debugger in the Edit Module at this point as Microsoft stopped supporting it quite some time ago, so R&D removed it a number of years ago, so you have to resort to other means for debugging things... Hopefully this allows you to figure out where the issue is occurring.
You likely stand a better chance of getting help on this one on the Microsoft forums as well given your code appears to be pretty much straight Windows/Excel API calls, I only see a couple QlikView APIs here. Sorry I am not more help.
Regards,
Brett