.net and excel
.net and excel
.net and excel
.net and excel
.net and excel
.net and excel .net and excel .net and excel .net and excel .net and excel .net and excel .net and excel .net and excel
.net and excel .net and excel
.net and excel
Go Back  Xtreme Visual Basic Talk > > > .net and excel


Reply
 
Thread Tools Display Modes
  #1  
Old 02-23-2009, 02:53 PM
revo09 revo09 is offline
Newcomer
 
Join Date: Feb 2009
Posts: 4
Question .net and excel


Hello everybody! I am currently making a programm from scratch, the same programm i made in vb6 some time ago. How works the following program? It sends data to calibrate a digital instrument, after which a timer comes in and sends a value to the instrument with a interval of 1000ms and it stores the received value in a string and it displays it in a texbox. It also sends it to excel in a user chosen cell using DDE. The think is I want the same result , but now in VB 2008 Express. I just want that a value stored in a string to be dinamically transmited in a excell cell. Really appreciate some detailed help.
Reply With Quote
  #2  
Old 02-23-2009, 03:35 PM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

Wow, that sounds like a lot... I think you should probably start with a smaller test project. Something simple.

To begin with, have a read of the Automating Office Programs with VB.NET tutorial. This will get you started on some of the basic changes that occur when switching from VBA or VB6 to VB.NET and Excel.

As for your particular needs for this project, there are a few issues I see:

(1) How you are "sending a value to the instrument"? If you could communicate with it using VB6 then you really should be able to using VB.NET. Is it a COM component?

(2) Controlling a TextBox on a Worksheet from .NET is an interesting challenge. But doable: see here. (Edit: Ok, wait, I think I misunderstood. If your TextBox is on your VB.NET form, then there are *no* special tricks required to control it and can ignore that thread.)

(3) I don't follow the DDE aspect. Is this a DDE formula within a cell? If not, please explain further.

Overall, I think you have a substantial project ahead of you. It should all be doable, but I thing you'll need to start off with something simple, get familiar with Excel & .NET, and built up from there...

Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb

Last edited by Mike Rosenblum; 02-23-2009 at 05:17 PM.
Reply With Quote
  #3  
Old 02-24-2009, 04:12 AM
revo09 revo09 is offline
Newcomer
 
Join Date: Feb 2009
Posts: 4
Smile trying to find a way

Thank you for your reply
First of all sorry, cause I forgot to mention. I am communicating with the instrument using the mscomm (ocx) component in vb6. In vb 2008 I am using the serialport component. When I send some data for example the character "D" through the serial port, the instrument replies back with the measured value which stores it in a string and displays it in a texbox. The main form in vb6 has the following properties:
Form1.LinkMode = 1 'acts as a source server continously sending requested values
Form1.LinkTopic = "data"
and i have a string
dim value as string
value = received data from serial port 'Which is continously updating because it's in a timer
In excel i have the following formula used to retrieve the data from the string within the vb6 application
=appname|data!value
It's very simple, works perfectly in vb6, and I want to implement the same thing but in VB2008 with another method because DDE is no longer available and if possible the way that excel retrieves the data to be the same (a formula) because its easy to handle.


Quote:
Originally Posted by Mike_R View Post

(1) How you are "sending a value to the instrument"? If you could communicate with it using VB6 then you really should be able to using VB.NET. Is it a COM component?

(2) Controlling a TextBox on a Worksheet from .NET is an interesting challenge. But doable: see here. (Edit: Ok, wait, I think I misunderstood. If your TextBox is on your VB.NET form, then there are *no* special tricks required to control it and can ignore that thread.)

(3) I don't follow the DDE aspect. Is this a DDE formula within a cell? If not, please explain further.
Mike
Reply With Quote
  #4  
Old 02-24-2009, 06:11 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

DDE link formulas still work in Excel. I think that this might be your best bet. Here is a simple explanation about how to set up the formula:

http://office.microsoft.com/en-us/ex...662101033.aspx

Another thought is to create a COM DLL that uses DDE to achieve what you want (basically code from your existing VB6 application) exposing commands such as 'SendViaDDE()' or the like and then call those commands from your VB.NET program. As long as your 'SendViaDDE()' command is public, you should have no problem setting a reference to your VB6 DLL and calling your method from .NET.

Otherwise, I don't have a clue about this component, you'd probably have to contact the manufacturer, or at least seek out documentation, I think...
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
  #5  
Old 02-24-2009, 09:56 AM
revo09 revo09 is offline
Newcomer
 
Join Date: Feb 2009
Posts: 4
Talking hmmm..

This is gonna be a difficult problem. I found that DDE was replaced by .NET remoting, and also found a rather hard example to follow using classes for a making a kind of "DDE link". I will try them and post here my down's and up's.

Anyways, here is a new question.

I know how to open an existing excel file from visual basic or how to create one, but is there a way for visual basic to write to an already opened excel file? (to search if its opened and then write in a specific cell?). For example to search if "test.xls" is open and then go for instance in the first cell and write some data.
Reply With Quote
  #6  
Old 02-24-2009, 10:54 AM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

Quote:
Originally Posted by revo09 View Post
This is gonna be a difficult problem. I found that DDE was replaced by .NET remoting, and also found a rather hard example to follow using classes for a making a kind of "DDE link". I will try them and post here my down's and up's.
Yes, this really does seem to be an unreasonable undertaking for a first project. You're going to have to learn how to walk before you can run, I think.

Quote:
Anyways, here is a new question.

I know how to open an existing excel file from visual basic or how to create one, but is there a way for visual basic to write to an already opened excel file? (to search if its opened and then write in a specific cell?). For example to search if "test.xls" is open and then go for instance in the first cell and write some data.
Well, unless you opened it yourself, then it is not open. Or are you hijacking the users Excel application instance via GetObject()? (I don't recommend this.)

If you had to, you can check if a Workbook instance is open by attempting to retrieve it from the Excel.Appilation.Workbooks collection. If you fail to find the workbook with the name you want, it is not open. Something like this:

Code:
Dim xlApp As New Excel.Application

Dim wb As Excel.Workbook
Try
    wb = xlApp.Workbooks("Test.xls")
Catch ex As Exception
End Try

If wb Is Nothing Then
    MessageBox.Show("Workbook not found! :-(")
Else
    MessageBox.Show("Workbook was found. :-)")
End If
In order to write a value to a specific cell, you should have a look at the Automating Office Programs with VB.NET, which covers this as well as a lot of other basic information you will need for automating Excel when using .NET.

-- Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
.net and excel
.net and excel
.net and excel .net and excel
.net and excel
.net and excel
.net and excel .net and excel .net and excel .net and excel .net and excel .net and excel .net and excel
.net and excel
.net and excel
 
.net and excel
.net and excel
 
-->