473,322 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

COM Interop Excel: Let the user quit the application

125 100+
I made this progarm in Visual studio 2005 vith COM Interop, I want to change the program so it does'n turn of excel and let the user control the application insted after the macro have run.

Expand|Select|Wrap|Line Numbers
  1.         Dim oExcel As Excel.Application
  2.         Dim oBook As Excel.Workbook
  3.         Dim oBooks As Excel.Workbooks
  4.  
  5.         'Start excel
  6.         oExcel = CreateObject("Excel.Application")
  7.         oExcel.Visible = True
  8.         oBooks = oExcel.Workbooks
  9.  
  10.         'Walkaround för bug
  11.         'http://support.microsoft.com/default.aspx?scid=kb;en-us;320369
  12.         Dim oldCI As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
  13.         System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
  14.  
  15.  
  16.         oBook = oBooks.Open("C:\ASEDT.xls")
  17.  
  18.         'Run macro / sub rutine
  19.         oExcel.Run("MyOpen", parameter)
  20.  
  21.         'Close the wokbook and quit Excel
  22.  
  23.        oBook.Close(False)
  24.         System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
  25.         oBook = Nothing
  26.         System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
  27.         oBooks = Nothing
  28.         oExcel.Quit()
  29.         System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
  30.         oExcel = Nothing
  31.  
  32.         'Walkaround för bug
  33.         System.Threading.Thread.CurrentThread.CurrentCulture = oldCI
  34.  

What lines to remowe?? i guess those marked with: <--**


Expand|Select|Wrap|Line Numbers
  1.        oBook.Close(False) <--**
  2.         System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
  3.         oBook = Nothing
  4.         System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
  5.         oBooks = Nothing
  6.         oExcel.Quit() <--**
  7.         System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
  8.         oExcel = Nothing
  9.  
Sep 22 '08 #1
1 1641
asedt
125 100+
Still nothing.. :(


I guess that i need to free the Objets in the program to avoid some memory leaks? but don't "turn off the excel objects". Is my thinking somewath right?
Sep 26 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet...
2
by: Ronny Sigo | last post by:
Hello all, As one of a few ways to let a user bring in data into my database I have made 3 excel files. Once the data are in the excel files my program checks if a required value (Taal (Dutch)...
1
by: Rick Brown | last post by:
After reading 30+ threads on the subject and implementing pertinent changes I still have an instance of Excel that won't close. I hope its due to my poor coding and someone can spot the error....
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
8
by: ChrisBowringGG | last post by:
When you use Application.Quit() on an Excel application, there can still be an instance of Excel running, as seen in Task Manager. You can try following the advice on MSDN: ...
2
by: Alex D. | last post by:
Hi .I cant seem to find a way to authorize asp.net user to create an Excel application using this: Microsoft.Office.Interop.Excel.ApplicationClass excel = new...
9
by: Anthony | last post by:
To me, creating Excel 2003 spreadsheets programmatically via VB.NET hasn't really changed since the days of VB6. That is, I'd do something similar to this Code: Dim ExcelApp As...
0
by: Delforce | last post by:
Hi all, My application allows you to create a new excel file and then double click it in the list view to start it in excell. If the excell file is an existing one then I can start it now...
1
by: Geoff | last post by:
Hello I am having an issue with my code below not closing EXCEL.EXE when I tell it do. Any help would be appreciated. ----- Dim excel As Microsoft.Office.Interop.Excel.Application Dim wb...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.