Excel VBA: Open file - how it works
Related Videos: Excel VBA: Check If File or Folder Exists (DIR) - Open File or Create Folder (May 2024).
As a VBA or Excel layman, you are sometimes faced with the problem of having to open an Excel file from another Excel file with VBA. We'll show you which command works.
Excel VBA: Open file
- Open a file in Excel using VBA with the command line "workbooks.open" x: \ blub \ ihrpfad.xls ", replacing" yourpath "with the path to the file you want to open.
- Alternatively, you can also automatically open a file, for example if you want to check whether a certain value in a line has been exceeded or fallen short of.
- To do this, press the key combination [ALT] + [F11] and double-click on the table you want to check. Then enter the command "if [A1] .value> 10 then workbooks.open" x: \ blub \ ihrpfad.xls "end if"
- In our example, such a table would be opened if the value A1 is greater than 10. Of course you have to adapt the command to your question.
If you would like to get to know VBA better, you will find the answer to the question "VBA - what are arrays?" In the next practical tip.