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: 
pgalvezt
Specialist
Specialist

Problem QlikView Macro Export to Excel

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

 

1 Reply
Brett_Bleess
Former Employee
Former Employee

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

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.