Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Create Excel Macro

Hi Qlikview experts!!

I'm having a trouble with a macro that creates an Excel file. The problem is that it works in my desktop using Qlikview (11.20.12664.0 SR9 64 bit) and Excel 2013 64 bits, works in a server that the client have to do some tests Qlikview (11.20.13206.0 SR13 64 bit)  and Excel Plus 2010 32 bits but it doesn't work in the production server Qlikview (11.20.13206.0 SR13 64 bit)

and Excel Plus 2013 32 bits .

I already checked in User Preferences Allways Override Security options and in the macro have Requested Module Security - System Access and Current Local Security - Allow System Access.

This is the macro:

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub Create_Excel

set XLApp = CreateObject("Excel.Application")

XLApp.Visible = False

XLApp.DisplayAlerts = False

set XLDoc = XLApp.Workbooks.Add

XLDoc.Sheets(1).name = "Export"

set XLSheet = XLDoc.Worksheets(1)

set MyTable = ActiveDocument.GetSheetObject("TB01")

set XLSheet = XLDoc.Worksheets(1)

XLSheet.Name="PlayersInfo"

Mytable.CopyTableToClipboard true 'Copy data to Clipboard

XLSheet.Paste XLSheet.Range("A1")

XLSheet.Range("1:1").Delete

XLDoc.SaveAs "E:\QVModels\4_XLS\PlayerSummary.xls"

XLApp.Quit 'finish

Set XLApp = Nothing

Set Table = Nothing   

ActiveDocument.Save

Application.Quit

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Doesn't give me and error, just doesn't work. It stops in set XLDoc = XLApp.Workbooks.Add

Any idea? Do I need a plugin or something?

Thanks!!

1 Solution

Accepted Solutions
sasiparupudi1
Master III
Master III

Try

Sub Create_Excel

Set XLApp = CreateObject("Excel.Application")

XLApp.Visible = True

XLApp.DisplayAlerts = False

Set XLDoc = XLApp.Workbooks.Add

XLDoc.Sheets(1).name ="PlayersInfo"

Set XLSheet = XLDoc.Worksheets(1)

Set MyTable = ActiveDocument.GetSheetObject("TB01")

Mytable.CopyTableToClipboard true 'Copy data to Clipboard

XLSheet.Paste XLSheet.Range("A1")

XLSheet.Range("1:1").Delete

XLDoc.SaveAs "C:\aps\PlayerSummary.xlsx"

XLApp.Quit 'finish

Set XLApp = Nothing

Set Table = Nothing  

End Sub

View solution in original post

4 Replies
sasiparupudi1
Master III
Master III

Try setting

XLApp.Visible = True

XLApp.DisplayAlerts = True

hth

Sas

sasiparupudi1
Master III
Master III

Try

Sub Create_Excel

Set XLApp = CreateObject("Excel.Application")

XLApp.Visible = True

XLApp.DisplayAlerts = False

Set XLDoc = XLApp.Workbooks.Add

XLDoc.Sheets(1).name ="PlayersInfo"

Set XLSheet = XLDoc.Worksheets(1)

Set MyTable = ActiveDocument.GetSheetObject("TB01")

Mytable.CopyTableToClipboard true 'Copy data to Clipboard

XLSheet.Paste XLSheet.Range("A1")

XLSheet.Range("1:1").Delete

XLDoc.SaveAs "C:\aps\PlayerSummary.xlsx"

XLApp.Quit 'finish

Set XLApp = Nothing

Set Table = Nothing  

End Sub

Anonymous
Not applicable
Author

Hi Sasidhar!!

I tried what you suggested but it didn't work I got the same, no error error just doesn't work.



Thanks!!!


Anonymous
Not applicable
Author

Hi Sasidhar!!

Thanks a lot, this works very good. I can run my macro now.

Thanks!!