Vba 在宏中打开一个电子表格

Vba 在宏中打开一个电子表格,vba,excel,Vba,Excel,目前,我有一个从互联网下载Excel文件的sub。我想在子结尾之前打开电子表格并在其上运行更多命令 With appIE .Navigate "https://www.alerian.com/wp-content/uploads/AMZmembers.xls" .Visible = False Application.Wait Now + TimeValue("00:00:03") SendKeys "{Enter}" End With Application.W

目前,我有一个从互联网下载Excel文件的sub。我想在子结尾之前打开电子表格并在其上运行更多命令

With appIE
    .Navigate "https://www.alerian.com/wp-content/uploads/AMZmembers.xls"
    .Visible = False

   Application.Wait Now + TimeValue("00:00:03")
   SendKeys "{Enter}"
End With

Application.Workbooks("AMZmembers.xls").Close 
问题是,直到宏执行完毕,电子表格才会打开,因此它无法找到工作簿

With appIE
    .Navigate "https://www.alerian.com/wp-content/uploads/AMZmembers.xls"
    .Visible = False

   Application.Wait Now + TimeValue("00:00:03")
   SendKeys "{Enter}"
End With

Application.Workbooks("AMZmembers.xls").Close 
SendKeys“{Enter}”打开工作表,但直到sub完成,它才会打开;因此,Workbooks.close找不到工作表,因为它尚未打开

With appIE
    .Navigate "https://www.alerian.com/wp-content/uploads/AMZmembers.xls"
    .Visible = False

   Application.Wait Now + TimeValue("00:00:03")
   SendKeys "{Enter}"
End With

Application.Workbooks("AMZmembers.xls").Close 
谢谢你的帮助

使用
工作簿。打开“路径和文件名”
而不是
发送键
Open
方法中还有一系列其他参数,例如是否希望以只读方式打开,等等,但最简单的方法如图所示

With appIE
    .Navigate "https://www.alerian.com/wp-content/uploads/AMZmembers.xls"
    .Visible = False

   Application.Wait Now + TimeValue("00:00:03")
   SendKeys "{Enter}"
End With

Application.Workbooks("AMZmembers.xls").Close