Suppose I have the following set up in a WinForms application:
Dim ExcelApp As Microsoft.Office.Interop.Excel.Application
Dim ExcelWorkbook As Microsoft.Office.Interop.Excel.Workbook
Dim wksDataVals As Microsoft.Office.Interop.Excel.Worksheet
ExcelApp.Visible = False
Basically, I have an invisible instance of Excel running in the background with a workbook open in it called ExcelWorkbook
and a sheet the app is manipulating called wksDataVals
. And the user is manipulating this sheet (and others) via the userform and seeing some outputs based upon those manipulations.
Now, on my form I have a button Show Excel Sheet
where, once the user clicks it, I want to show them a copy of wksDataVals in a new, standalone, workbook while keeping the original hidden in the background for further data manipulation. I believe that I need to do this by creating a new instance of Excel since I want to keep this one hidden.
Is there a better way to do this than:
(Which can create an issue with the worksheet now only being read-only since I want it to stay open in the other Excel instance) - I know I can overcome this by re-saving the worksheet as a new name AGAIN, but this all seems like overkill.
Any ideas about how I can accomplish this in the easiest way?? - Maybe there's a way to save the workbook / sheet internally and feed it to a new Excel instance rather than making Excel try and open a saved sheet??
Thanks!
As an answer to my own question in case anyone out there happens to have the same question come up for them (please, experts, if you have a better way, let me know), what I ended up doing was:
Seemed to do the trick wonderfully.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.