M
M
Maxim Nikitin2015-06-08 14:31:22
Visual Basic
Maxim Nikitin, 2015-06-08 14:31:22

How to open an Excel document in a separate process?

When the application is running, a report is written to Excel. If at the same time another document is opened in Excel in parallel, then the following code will close both the Excel document opened using COM and the file that is not related to the application:

Dim w As Workbook
        For Each w In mExcel.Workbooks
            w.Save()
        Next
 mExcel.Quit()

As far as I understood by googling, this is a feature of Excel 2013 - to open documents in one process. Tell me how to open Excel using COM in a separate process? Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2015-06-08
@Sumor

Quit will always close all documents that are open.
There are several ways out: First, the created book should be closed using the Close() method. Further, before creating reports, you can count the number of open books in the connected Excel, and if there were no open books, you can safely close the Quit method, if there were open books, then do not close.
Secondly, when creating and connecting to COM, you can specify that a new instance of Excel is required. Unfortunately, this parameter is often hidden behind com wrappers and is not available for passing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question