Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
I needed to add these two lines of code before the .Select line
XLS.Worksheets("JanData").Visible = True
XLS.Worksheets("JanData").Activate
I needed to add these two lines of code before the .Select line
XLS.Worksheets("JanData").Visible = True
XLS.Worksheets("JanData").Activate