Office Automation :: Multi-threaded Real-time Data Handling In Excel With COM

Jun 22, 2010

I have an Excel based algo-trading app that needs to take in lots of real-time data, and make trading decisions based on the calculations driven by the data. It is not one of those "read-only" stock ticker kinda spreadsheets.I created a COM object with VB.NET that runs in its own thread space which collects data from a socket, and when the data is read it raises an Event with data attached. In Excel VBA, the event handler parses the data, puts them to the right places on the spreadsheet to feed calculations (so far it sounds like a stock ticker app), and then, based on the results of the various calculations it does something.The problem is that when the user starts to click around the spreadsheet while there is large amount of data coming, the event handler's cell updating breaks apart. If the app is left alone without user action, it stands well. My frustration comes from not understanding what happens to the main thread when a user clicks around. Either the event handler blocks the user action, or the user action blocks the event handler (under which case I will put in some queuing facility). But I just don't see how user action can break the code (like causing VBA to stop executing)

View 9 Replies


ADVERTISEMENT

Excel Automation For Real-time Data

Jun 5, 2012

i have a program that function as a DAQ System.i have input channel to gather information from sensors. The reading of each sensor such as voltage, current and temperature are displayed in the textbook. As we all know, DAQ system is involve taking data real-time measurement.My problem is:

1. how to update each row automatically as time goes on. the value in the textbook is updated by each second.Below figure shows how the excel can be written automatically row by row, as time ticking for a sec. this update will stop as the timer stop.

View 12 Replies

Office Automation :: PPT Automation = Multi-threading And RPC Server Unavailable

Apr 16, 2010

I have successfully automated a PowerPoint Metrics presentation with VB.Net. However, since there were many complicated calculations, it took quite some time to make the 120+ slide presentation - so I recently tried to revamp the application to be multi-threaded.

[Code]...

View 1 Replies

Office Automation :: Exporting Data To Excel

Feb 16, 2010

I've made an application, that allows to export some data to an exisiting excel-file. Everything works fine on my system, but not on other OS where Visual Studio is not installed. The xls file is simply not being edited at all.[code]

View 1 Replies

Real Time Form Updating - Keep Single Threaded - Ongoing Maintenance

Dec 14, 2009

I have an app that I'm trying to keep single threaded, mostly for reasons to do with simplicity of ongoing maintenance. I've structured it so that I can eventually multi-thread it if need be but I'd rather not at this point. It's semi-real time and does perpetual looping to display a number of different graphs and do various work with both the graph display and the work being hosted in their own respective objects. If you're familiar with the Windows dispatch manager it's that general paradigm run synchronously. And yee haw, it pretty much works at this point and runs fast enough to meet requirements by a happy margin. I have a cosmetic problem that I'd like to solve if I could. When I left-click and move any form around, my graphs stop updating until I release the left click button. I was thinking about a doevents somewhere in the click event catalog.

View 1 Replies

Office Automation :: Data Transfer From Datagrid To Excel?

Jul 8, 2009

I have the following code which works fine. However, I want to change one format when I export it to excel ..

Colum 3 is Sort Code and have the format 00-00-00, I want to change it to 000000 i.e., remove the dashes.

When exported to excel I use a formalue (Substitute(A1, "-", "") and this removes the dashes. But what I want to do is remove the dashes before exporting to excel... see the code below for datagrid - excel export, highlighted is where I think the one line code should be...

Code:
Private Sub ExporttoExcel()
'verifying the datagridview having data or not
If ((DgvQuarCommit.Columns.Count = 0) Or (DgvQuarCommit.Rows.Count = 0)) Then

[Code]......

View 7 Replies

Office Automation :: Export Data From Datagrid To Excel?

Mar 1, 2010

I am working with Vb.net and this code below works fine. However, when I review the data exported to excel I have a problem with one particular field i.e., sort code,( Columns (2) ) Sort code in the database it is in the format 00-00-00. Therefore if it is 12-11-09 or 11-01-66, a look alike of a valid date it is displayed as 12/11/2009 and 11/01/1966 in excel after the export. Excel thinks its a date which is incorrect. I expect it to show 12-11-09 and 11-01-66.

Private Sub ExporttoExcel()
'verfying the datagridview having data or not
If ((DgvQuarCommit.Columns.Count = 0) Or

[code].....

View 4 Replies

Office Automation :: Fill An Excel File With Some Data?

Dec 13, 2011

In my app I need to fill an excel file with some data. On change of customer the data needs to be on another worksheet, sheet renamed and so on.

The workbook now has 19 sheets (wSheet.Add(,,16), the first worksheet gets renamed to custno. and the sheets gets filled.

But whatever I try, I can't get onto the other worksheets.

All I Googled seem to raise errors; following code is part of a nested 'If'

Code:
Dim excel As New Microsoft.Office.Interop.Excel.Application
Dim wBook As Microsoft.Office.Interop.Excel.Workbook
Dim wSheet As Microsoft.Office.Interop.Excel.Worksheet
If w < 1 Then

[Code].....

View 1 Replies

Office Automation :: Transfer Data From Textboxes To Excel

Mar 24, 2010

i want to transfer data from my textboxes to excel but in the same sheet because the data that i have is more than 50 lines and i want to put it little by little in the same sheet instead later to make some calculations in excel.i have code that is working but each time i click it creats a new book a new sheet i dont want that i want to add data in the the same sheet.

View 10 Replies

Office Automation :: Transferring Data From Excel To Access?

Jun 28, 2010

I have written a VBA code in EXCEL that updates my tables in Access. The code is fully functionnal when I am entering new data but I don't know how to make it work when a data (primary key) already exists and that I need this data for another table. I would like to find a code in this format (DAO) :

If value exists in table Then
Return the value.code (not the value but the code related to this value)
else
.addnew

here is what I have tried but does not work:

Code:

Function Find_Last_EngineCode() As Integer
Dim cn_engine As ADODB.Connection, rs_engine As ADODB.Recordset, feuille As Worksheet, plage As Range, last_record As Integer
Set feuille = Application.ThisWorkbook.Worksheets("To_Access")

[code]....

View 1 Replies

Office Automation :: Excel Automation - Cannot Use Office PIAs

Feb 14, 2009

It appears that when one creates an instance of Excel, using CreateObject, (Late binding), the suggested Excel closing function (with GC.collect etc) does not work. I have tried several suggestions, and the only one that works is process.kill method. Do you see any problem in using this? BTW: the reason we are using late binding is that we cannot use Office PIAs....not sure which version of Office would be installed on the client site. We work with O2003, but the client might still be at 2000 or 2002.

View 7 Replies

Transfer Real Time Data From Vb 2005 To Excel?

Nov 24, 2009

I am working on a project that is able to display real time data from sensors from micro-controller. I am able to do so by sending the data through the serial port and then use vb 2005 to show the data. However, I want to save those data from vb 2005 to excel. How am I able to do it ? I am able to use vb to insert data to excel step by step, cell by cell using the following codes.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object

[code]....

Lets say TextBox1.Text and TextBox2.Text is my real time data. How do I save it to the excel sheet displaying the data in cell A2, A3, A4 when the time goes by. Eg. If I want to save TextBox1.Text to excel it would be, the data in the 1st seconds in cell A2, data in the 2nd seconds in A3, 3rd seconds A4, 4th seconds in A5, A6 and so on...

View 3 Replies

Office Automation :: Create An Excel Document With A Series Of Columns That Contain Data To Import Into VB 2008

May 31, 2010

Ok, what I would like to be able to do seems simple enough. I would like to be able to create an Excel document with a series of columns that contain data to import into Visual Basic 2008

[Code]...

View 1 Replies

Office Automation :: Reading Excel Using OLEDB - Wrong Data Type For Column Returned?

Jul 1, 2009

I am trying to read some data from an Excel 8.0 worksheet using OLEDB thusly:(Warning - contains curly braces)

Code:
DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");
using (DbConnection connection = factory.CreateConnection())
{

[code]....

The problem is that for some columns it sets the data type to be Double even though the spreadsheet column format is "Text" and teh column contains non-numeric data. Then when it gets to that cell it returns DBNull instead of the text value.

View 1 Replies

Office Automation :: Automatic Deployment Of Excel Automation Addin?

Jan 25, 2011

I have written an automation addin in Excel with C# (addin.dll). To use the addin, I need to 1. register it using "regasm /codebase c:...addin.dll"2. select in ExcelOptionsAddInsExcel AddinsAutomation the respective addin from the list

I would like to automatize 1) and 2), so that the user just needs to run an exe-file in order to use the addin. 1) should be no problem, but how can one automatize 2)?

View 12 Replies

Office Automation :: Excel 2003 Automation With VB 2005 Express?

Apr 20, 2010

Ok basically what I need to do is the following:Read FirstExcelDoc (attached)For every row in that: Retrieve data from sql server db based on info in the Orange columns of FirstExcelDoc Let's say I retrieved data elements A, B, C, D, and E from sql server. Then I need to enter those same data elements A, B, and C in another excel spreadsheet (which has formulas etc) After inputing A, B, and C in that spreadsheet, read a couple of calculated fields and compare those results to data elements D and E retrieved originally from SQL Server DB. Finally, output the results in the Blue columns of the FirstExcelDoc spreadsheet for that row.Loop through and do the same thing for row 2 of the FirstExcelDoc and keep on until you see "END TEST" in the FirstExcelDoc.

I'm looking for a method of doing this efficiently. I have read several articles over the past few days as well as those from Mike R. but just need some direction to get started on this.To start of I'm looking for whether to read the entire FirstExcelDoc spreadsheet or just read the info for first policy number(2nd row) and process it and write out the blue column info for that row and then loop through and come back and read the second policy number (3rd row) etc... Please attach a code snippet for either way of reading the data.

View 19 Replies

Office Automation :: Orphan Excel Process Started Via Automation

Jun 17, 2009

I'm using excel via interop in application.Sometimes users kill application that created excel instance and that results in excel instance sitting in memory without any chance of disposing it.First I tried to tackle this using ROT(running object table) looks like not all instances of excel are registered there.Than I tried to somehow mark excel process after it is started via interop.[code]This works as long as excel is visible but in my case excel window is invisible.All I need is to somehow mark process that started via automation with the parent PID, so that later I can kill it if parent does not exist.

View 19 Replies

Communications :: Real Time Data Collection From Socket And Storing In Excel

Jan 5, 2012

I m into automation development of FMCG products using Micro-controllers. I get real time data Barcode 2D from TCP/IP connection. My task is to compare the result do some Computation with them and Store the incoming Barcode and results into a Excel sheet in a folder. I m successful with the basic working. Am currently working at slow speed of 1 barcode(22 char info) per second from the TCP/IP data (barcode scanner). Now, comes the real issue. I need to process atleast 5 barcodes per sec ( <200ms per process). I m partially successful with 3 Barcode per second(300 ms per process). so, thats like 300ms per processing. I need to achieve less than 200ms for entire processing. I have used threads and timers. but I m unable to achieve. Seems like storing in Excel takes more than 250ms. Since i come from micro controllers background 1msec is a lotta time to process for me. I m not sure how much time does it take and trust me i find it difficult to guage the time here.

View 1 Replies

Office Automation :: Excel Automation - Call Rejected

Dec 17, 2010

I have been pulling my hair out trying to fix this.

[Code]....

View 1 Replies

Office Automation :: Excel Automation Causing: Rpc_e_serverfault

Jun 1, 2010

We have a vb program which is run on our server by scheduled task every day. The program opens about 30 excel files, refreshes the data connections, pivot tables and then saves the document in another location.

This may run fine for a couple days but sooner or later the process starts crashing, usually with this error: RPC_E_SERVERFAULT.

My question is, Is it expected that continually opening/closing/refreshing workbooks will inevitably cause the Excel object to crash at some point.

View 3 Replies

Office Automation :: MultiThreading In MS Office 2007 (Excel, Outlook, Etc)?

Mar 28, 2011

i was wondering if someone could give me the final explanation on what i might be doing wrong here.I spent a lot of time reading around the net and the forum about how to add Threading capabilities to a VB project.

Nos, i've got .NET 4 installed, and i've added the system.tsr and mscorlib.dll files as reference in, say, Excel 2007 (see screenshot).However, when i try to make a thread with anything as basic as "Dim Thread1 As System.Threading.Thread", i get a user-defined type not found error.Indeed, when i use the object browser to see what's in the System file, theres nothing remotely linked to any Threading, and in the mscorlib file, nothing under "Threading" either, just a few Thread related functions, but nothing defining a data type

View 2 Replies

Office Automation :: .net Automation Excel App Not Closing

Sep 25, 2009

I'm having an issue where my excel.exe process doesn't close until I close my .net application. I'd like to avoid using Process.Kill() if at all possible.

Code:

Private Sub WriteRowsToXls(ByVal rows As DataRowCollection, ByVal xlsPath As String, ByVal showStatus As Boolean, Optional ByVal AddTotals As Boolean = True)
Dim xlsApp As New Microsoft.Office.Interop.Excel.Application

[CODE]............

This method references a couple of other methods I use for repeated formatting tasks, I'll include those methods below. (I added the FinalReleaseComObject into the other methods after reading Mike's thread but the issue persists)

Code:
Private Sub SetRangeValidation(ByVal rng As Range)
With rng.Validation
.Delete()

[CODE]..............

Method SetRangeAllBorders does about the same as these other methods but my post is too long to add it. The only other things not shown in these code snippets are a few string variable that are defined in the class, studentWS, studentsWSPW, paymentsWS and paymentsWSPW My App creates an instance of the class, loads some data, runs the method above, and then sets the class to nothing. I'm using .NET 3.5 automating Excel 10

View 2 Replies

Office Automation :: Automation Excel Without Install Excel

May 28, 2009

I am developing an application using excel automation.The worst thing is the client's side doesn't have excel installed.What is the solution for this case?

View 17 Replies

Office Automation :: Excel File - Set A Reference To The Microsoft Excel 12.0 Object Library

Oct 6, 2009

I'm trying to upgrade a VB6 app to VB 2008. I have read the article in the tutors corner about automating Excel from VB but I cannot get it to work. Heres what I have done:

1) set a reference to the Microsoft Excel 12.0 Object Library

2) Added "Imports Excel = Microsoft.Office.Interop.Excel" to the top of the module

3) in a routine I have added: Dim X As New Excel.Application Here's where I get an error: Error 75 'Application' is ambiguous in the namespace 'Microsoft.Office.Interop.Excel'.

View 6 Replies

Office Automation :: Excel Program Leaves EXCEL.EXE Floating After Completion

Feb 24, 2012

I am writing a program that loops through all of the sheets in an Excel workbook and saves each sheet as its own workbook. It turned out to be a bit trickier than I expected, since the Sheet.Copy method creates a strange object (see here for the MSDN discussion that I believe is relevant: [URL]. Anyway, I found a Stack Overflow post [URL] that got me to where I am, which is essentially complete, outside of one hanging EXCEL.EXE process that is left after the program completes, which I believe is a result of the sheet.copy method creating a new workbook (potentially a new application as well?). The other thing I run into, which I believe is related to this, is that even though I have my application set to visibility off, when I run the program, excel still opens up and is visible going through the steps.

Here is my code:

Code:
Imports System.Data
Imports System.IO
Imports Microsoft.Office.Interop

[CODE]...

Now I think the problem comes from the end of the loop, where I try to close the export file and the new worksheet it creates:

Code:
'close excel and release com objects
System.Runtime.InteropServices.Marshal.ReleaseComObject(exportsheet)
exportsheet = Nothing
xlApp1.Workbooks(fileNames(counter - 1)).Close(False)

I can't figure out what to do to release the `ComObject` for the new worksheet that is created. I have been trying all sorts of things, but it always throws a COM error when I do it and if I try to define it as nothing (like I do with exportsheet) is says that it is read only by default, so I can't do it. It seems like it should be something as simple as: System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp1.Workboo ks(fileNames(counter - 1))) But that is not the case. I have tried a few variants of this and I am thinking it has to do with the MSDN link above, but I can't quite sort out what to do. So the code works for my purposes, outside of leaving one EXCEL.EXE after it is done. As far as a test file, I am just using an Excel file with 3 sheets and I put some information on each and change the sheet name, so it is easy to see if it is working or not.

View 1 Replies

Office Automation :: Code Hangs When An Excel File Is Opened To A Excel Workbook Object?

Aug 3, 2009

I use the following code snippet

Dim exlapp As New Microsoft.Office.Interop.Excel.Application
Dim xlWorkBook_new As Microsoft.Office.Interop.Excel.Workbook
Dim strOriginal As String
strOriginal = Server.MapPath(Request.ApplicationPath & "/Attachments/") & "abc.xls"
xlWorkBook_new = exlapp.Workbooks.Open(strOriginal)

The code hangs in the last line. It works fine in the development environment. i deployed in windows server 2000 ,where I get this issue. the browser goes half way and throws the below exception after some time

[Code]...

I have set the identity impersonate to true in web config. This should be mostly an access rights issue.I have even provided access rights for the "everyone " user in the excel file and as well for the interop component. Please post ur valuable comments.

View 3 Replies

Office Automation :: Error With Excel Dll On Server Without Excel?

Jun 15, 2011

We have a VB 2005 program that reads data from a database and builds an Excel output file to be emailed. This works fine from my computer but when we put it on the server it fails on the Excel functionality.

The error is: Unhandled Exception: System.Runtim.InteropServices.COMException

Although Excel is not installed on the server we did also build a Setup program to install our program. It copies the Microsoft.Office.Interop.Excell.dll to the server folder with the exe.I thought the setup program should register the Excel DLL and the program should work even if the server does not have Office or Excel installed.

View 3 Replies

Office Automation Using Excel And .Net?

Aug 7, 2009

when the worksheet is built i get the error message "Object reference not set to an instance of an object.".Here is my code:

Code:

Dim myXLApp As Excel.Application
Dim myXLWbs As Excel.Workbook
Dim myXLSht As Excel.Worksheet

[code]....

View 1 Replies

Office Automation :: Add A Combobox To Excel

Jun 19, 2012

I am creating a new software with visual studio 2010 using the program language visual basic .NET, well in that software I create a new file in excel 2007, my question is because I do not know how I can create a combobox with data of my database inside, [code]

View 2 Replies

Office Automation :: Closing Excel.EXE From App?

Jun 9, 2010

I work for a financial firm doing vb.net work.I open an excel doc and populate it using calls to range...i however dont dim the range...I call xlsSheet.Range.ValueI have about 30 ranges i update in this method before printingdo i need to set the .Range.Value to Nothing in order to close the excel.exe

View 9 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved