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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

excel macro to select a tab and a data table in a qvw file and pull the data from the same.

Hi All,

I want to come up with a excel macro which will select a tab from a qvw file first and then select a data table in the same and pull the data from that data table to excel worksheet. The qvw file is existing on a portal.

Thanks a lot for your help in advance.[:)]

1 Solution

Accepted Solutions
Not applicable
Author

Hi,
Not sure of doing it from Excel; but the below is the start & end portion of a macro written in Qlikview that is currently working for us; that selects a specific Qlikview tab, then a specific object & pastes it into a specified Excel template. This is also working for us via IE Plugin so maybe you can 'cobble' together what you need from it?

Sub Excel_Table_Export
set XLApp = CreateObject("Excel.Application")
set XLDOC = XLApp.Workbooks.Open ("C:\Templates\Test_Data.xlsx")
XLApp.Visible = True

'this is the qvw tab
set s=ActiveDocument.Sheets("Excel Exports")
ActiveDocument.Sheets("Excel Exports").Activate
ActiveDocument.ClearCache
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.GetSheetObject("CH38").Restore
ActiveDocument.GetSheetObject("CH38").CopyTableToClipboard true

'this is the sheet in Excel
set XLSheet = XLDOC.Worksheets("Sheet1")
XLSheet.Paste XLSheet.Range("A1")

XLSheet.SaveAs "C:\Data & " - " & [mynamevar] & " - " & [mydatevar] & ".xlsx"

set XLApp = Nothing
set XLDOC = Nothing
set XLSheet = Nothing

End Sub

Hope it helps!

View solution in original post

4 Replies
Not applicable
Author

Hi,
Not sure of doing it from Excel; but the below is the start & end portion of a macro written in Qlikview that is currently working for us; that selects a specific Qlikview tab, then a specific object & pastes it into a specified Excel template. This is also working for us via IE Plugin so maybe you can 'cobble' together what you need from it?

Sub Excel_Table_Export
set XLApp = CreateObject("Excel.Application")
set XLDOC = XLApp.Workbooks.Open ("C:\Templates\Test_Data.xlsx")
XLApp.Visible = True

'this is the qvw tab
set s=ActiveDocument.Sheets("Excel Exports")
ActiveDocument.Sheets("Excel Exports").Activate
ActiveDocument.ClearCache
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.GetSheetObject("CH38").Restore
ActiveDocument.GetSheetObject("CH38").CopyTableToClipboard true

'this is the sheet in Excel
set XLSheet = XLDOC.Worksheets("Sheet1")
XLSheet.Paste XLSheet.Range("A1")

XLSheet.SaveAs "C:\Data & " - " & [mynamevar] & " - " & [mydatevar] & ".xlsx"

set XLApp = Nothing
set XLDOC = Nothing
set XLSheet = Nothing

End Sub

Hope it helps!

Not applicable
Author

Hi Jon,

Thanks a lot for your reply, But I am looking for a excel macro which can perform the tasks mentioned by me in my initial post. I can use click view code because though I have qlikview installed on my system but the recepients to whom I will send this macro they may or may not have qlikview installed on the system. Actually they may be having only the Internet exlporer plugin installed on there system which allows them to open a qvw file which is available on a portal. So I want to come up with a excel macro which will help them to pull the data from the qvw file which they are able to open on the portal using the plugin.

Thanks a lot for your help in advance. Smile

Not applicable
Author

Hi All,

Did anyone get the chance to look into the above post ?.

Thanks a lot for your help in advance. Smile

prieper
Master II
Master II

You may also dump any table into a txt-file during script-execution, which then can be picked up by Excel (or automated via VB-scripts)

HTH
Peter