我正在使用Recordset通过循环Excel对象并创建一个新的Excel每次我打开它时将Access窗体中的5个查询导出到Excel。最后,当我想突出第一张时,它会抛出一个错误号:1004访问Excel导出
<code>
'Once the loop ends
xlWorkbook.Sheets("xlsheet1").Select
xlSheet.Range("A3").Select
</Code>
But when I select the last sheet which is by default highlighted I don't get the error.
<code>
'Once the loop ends
xlWorkbook.Sheets("xlsheet5").Select
xlSheet.Range("A3").Select
</Code>
Can someone help me with this.
Thanks in Advance.
您每次都在创建一个新的工作簿。第五个工作簿没有第一个工作簿中的工作表。你可以运行一个'xlWorkbook(1到5)'的数组。 – user3819867
另外,请使用'xlWorkbook.WorkSheets'。 – Gustav