Open File Without Calling Filepath

后端 未结 5 1427
太阳男子
太阳男子 2021-02-05 15:04

I\'m using excel VBA. I want to press a button that opens another file directly without the effect of \"choosing file window\".

This is the current code:



        
5条回答
  •  耶瑟儿~
    2021-02-05 15:38

    If the file is in the same folder as the document containing your VBA macro, use

    ThisWorkbook.Path
    

    for example:

    Workbooks.Open(ThisWorkbook.Path & "\ObsReportExcelWorkbook.xlsx")
    

    (this works even if the document is not the active one any more, or you changed the current directory).

提交回复
热议问题