Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Export Table Macro in QV 10

Hi All,

I am trying to write a macro to export data from a table from QV to an excel spreadsheet. I am new to this and so I am having trouble debugging and fixing the error that I am receiving. Here is the macro so far..

Set AD=ActiveDocument
Set MN=AD.Fields("Month_Name")
Set XLApp = CreateObject("Excel.Application")
Path = "RightPath"
FileName = "RigthFile.xls"

XLApp.Visible=True
Set XLS = XLApp.Workbooks.Open(Path & FileName)



XLS.Worksheets("JanData").Visible = True

'Jan
MN.Select "Jan"
ActiveDocument.GetSheetObject(6).CopyTableToClipboard True
XLS.Worksheets("JanData").Range("B1").Select
XLS.Worksheets("JanData").Paste()

****Then I get this error on the bolded and underlined row:"Select method of Range class failed"

Any suggestions as to why this macro errors out on this row would be great.

Thanks,

Austin

1 Solution

Accepted Solutions
Not applicable
Author

I needed to add these two lines of code before the .Select line

XLS.Worksheets("JanData").Visible = True

XLS.Worksheets("JanData").Activate



View solution in original post

1 Reply
Not applicable
Author

I needed to add these two lines of code before the .Select line

XLS.Worksheets("JanData").Visible = True

XLS.Worksheets("JanData").Activate