I want to search through existing Excel files with a macro, but I don't want to display those files when they're opened by the code. Is there a way to have them open "in the background", so to speak?
相关问题
- Excel sunburst chart: Some labels missing
- Error handling only works once
- Error handling only works once
- Excel formula in VBA code
- Excel VBA run time error 450 from referencing a ra
相关文章
- How to replace file-access references for a module
- Get column data by Column name and sheet name
- programmatically excel cells to be auto fit width
- Why is file_get_contents faster than memcache_get?
- Unregister a XLL in Excel (VBA)
- Unregister a XLL in Excel (VBA)
- Transactionally writing files in Node.js
- How to prevent excel from truncating numbers in a
Open them from a new instance of Excel.
You need to remember to clean up after you're done.
Open the workbook as hidden and then set it as "saved" so that users are not prompted when they close out.
This is somewhat derivative of the answer posted by Ashok.
By doing it this way though you will not get prompted to save changes back to the Excel file your reading from. This is great if the Excel file your reading from is intended as a data source for validation. For example if the workbook contains product names and price data it can be hidden and you can show an Excel file that represents an invoice with drop downs for product that validates from that price list.
You can then store the price list on a shared location on a network somewhere and make it read-only.
If that suits your needs, I would simply use
with the added benefit of accelerating your code, instead of slowing it down by using a second instance of Excel.
Not sure if you can open them invisibly in the current excel instance
You can open a new instance of excel though, hide it and then open the workbooks
As others have posted, make sure you clean up after you are finished with any opened workbooks
In excel, hide the workbooks, and save them as hidden. When your app loads them they will not be shown.
Edit: upon re-reading, it became clear that these workbooks are not part of your application. Such a solution would be inappropriate for user workbooks.
A much simpler approach that doesn't involve manipulating active windows:
From what I can tell the Windows index on the workbook should always be
1
. If anyone knows of any race conditions that would make this untrue please let me know.