On my form I have a routine Private Sub SendToExcel() in which I have this code:<br>
<br>
Dim objExcel as Excel.Application<br>
Dim objWorkbook As Excel.Workbook<br>
Dim objWorkSheet As Excel.Worksheet<br>
Dim objRange As Excel.Range<br>
<br>
I then open Excel as:<br>
<br>
Set objExcel = GetObject("", "Excel.Application"<br>
objExcel.Visible = False<br>
Set objWorkbook = objExcel.Workbooks.Add<br>
objExcel.DisplayAlerts = False<br>
<br>
The recorset is sent to Excel and formatted. I end with:<br>
<br>
Set objExcel = Nothing<br>
Set objWorkSheet = Nothing<br>
Set objWorkbook = Nothing<br>
Set objRange = Nothing<br>
<br>
I noticed during testing, that Excel was opening with a blank sheet but no errors occurred. I opened Task Manager and saw "Excel" listed 23 times, once for each time I ran the routine! <br>
<br>
The only time Excel was unloaded was if I ended my entire programme. My questions are:<br>
<br>
1. How to run only one Excel instance<br>
2. Unload Excel completely once this routine is finished.<br>
<br>
I certainly do not want 23 instances of this app.<br>
<br>
Thanks all - thank you, thank you!<br>
<br>
Nick<br>
<p>Nicholas, Bank of America NetO<br><a href=mailto: > </a><br><a href= > </a><br>
<br>
Dim objExcel as Excel.Application<br>
Dim objWorkbook As Excel.Workbook<br>
Dim objWorkSheet As Excel.Worksheet<br>
Dim objRange As Excel.Range<br>
<br>
I then open Excel as:<br>
<br>
Set objExcel = GetObject("", "Excel.Application"<br>
objExcel.Visible = False<br>
Set objWorkbook = objExcel.Workbooks.Add<br>
objExcel.DisplayAlerts = False<br>
<br>
The recorset is sent to Excel and formatted. I end with:<br>
<br>
Set objExcel = Nothing<br>
Set objWorkSheet = Nothing<br>
Set objWorkbook = Nothing<br>
Set objRange = Nothing<br>
<br>
I noticed during testing, that Excel was opening with a blank sheet but no errors occurred. I opened Task Manager and saw "Excel" listed 23 times, once for each time I ran the routine! <br>
<br>
The only time Excel was unloaded was if I ended my entire programme. My questions are:<br>
<br>
1. How to run only one Excel instance<br>
2. Unload Excel completely once this routine is finished.<br>
<br>
I certainly do not want 23 instances of this app.<br>
<br>
Thanks all - thank you, thank you!<br>
<br>
Nick<br>
<p>Nicholas, Bank of America NetO<br><a href=mailto: > </a><br><a href= > </a><br>