View Single Post
  #2   Report Post  
Jan Karel Pieterse
 
Posts: n/a
Default

Hi ExcelMonkey,

I just turned an xls file into an xla file and am having some issues with my
code. The code snippet below is failing on: Windows(varfile1).Activate.
varfile1 is the name of the xla file.


You cannot select an invisible window (all windows of an add-in are hidden),
you must work with the Workbook object instead. There is no need to select
things though. This snippet copies the "used range" of sheet varsheet1:

With Workbooks(varfile1).Sheets(varsheet1)
.Range(.Range("A1"), .Range("A1").SpecialCells(xlLastCell)).Copy
end With

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com