PC Review


Reply
Thread Tools Rate Thread

Data logging with a DDE link and VBA

 
 
=?Utf-8?B?RWxjZWxsZXIgaW4gZGlzdHJlc3M=?=
Guest
Posts: n/a
 
      18th Jul 2007
I have a created a spreadsheet that uses a DDE link to show values from plant
equipment. The information is displayed on four cells in sheet1. I have put
together a macro that copy’s the information from the four cells in sheet1
and pastes the information on sheet 2. This routine runs every second and
moves to the next cell. . It saves the information every seven hours and
starts over. In other words I know what the equipment was doing every second
during a 7 hour shift. The program seems to work fine when I test it in the
office, without the link and without letting it run 7 hours. When I leave it
running on the machine the program crashes, I have not seen the error that
comes up.

Will a DDE link cause any type of error that can stop the program from
running?
Is there a way to program around DDE errors?

This is the only program running on this computer can windows cause it to
crash in any way?

 
Reply With Quote
 
 
 
 
Thomas Lutz
Guest
Posts: n/a
 
      24th Jul 2007
A DDE Link should not cause any problems in an Excel spreadsheet as
long as the links are implemented correctly. It is more likely that
the problem is in whatever code is running every second. You may want
to throw in an error handler to record all the errors so that you can
track down what is going wrong.
A better way to do things might be to use the Excel SetLinkOnData
method to monitor the DDE data and trigger the macro that you are
currently triggering with a timer. The SetLinkOnData method lets you
configure a VBA subroutine to run automatically whenever data from a
DDE link changes. Using this approach, you would never miss a single
data value. With a timer taking a snapshot of the data every second,
you could easily miss data as well as record redundant data.


On Wed, 18 Jul 2007 11:58:00 -0700, Elceller in distress
<(E-Mail Removed)> wrote:

>In other words I know what the equipment was doing every second
>during a 7 hour shift. The program seems to work fine when I test it in the
>office, without the link and without letting it run 7 hours. When I leave it
>running on the machine the program crashes, I have not seen the error that
>comes up.
>
>Will a DDE link cause any type of error that can stop the program from
>running?
>Is there a way to program around DDE errors?
>
>This is the only program running on this computer can windows cause it to
>crash in any way?

 
Reply With Quote
 
=?Utf-8?B?RWxjZWxsZXIgaW4gZGlzdHJlc3M=?=
Guest
Posts: n/a
 
      24th Jul 2007
Thanks for your help Thomas,

I am new to error handles,
In every sub I am guessing I need to add:

"On Error GoTo ErrorHandler"?

Then also add a sub called "sub Errorhandler()"?

What code would I use to store the error?

Sub errorhandler()
???
end sub

For reference purposes, I have attached a portion of my program. I just
took a piece of it so it will not work.










sub controller()

If time = TimeSerial(19, 0, 0) Then
ExportandSave
insertsheet
FormatSheet
ResetRange
Setnewtime
setoldtime
test

Else

If OldTime < NewTime Then
ZeroScan = False
setoldtime

Rng1 = Rng1 + 1
Rng2 = Rng2 + 1
getrange

Sheets("Sheet1").Range("A2:g2").Copy


Sheets(Sheetname).Range(InsertRange).PasteSpecial
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets(Sheetname).Range(DTETMEInsertRange).Offset(0,
7).Value = Date
Sheets(Sheetname).Range(DTETMEInsertRange).Offset(0,
8).Value = time


ElseIf NewTime = 0 Then
OldTime = 0

If ZeroScan = False Then

Rng1 = Rng1 + 1
Rng2 = Rng2 + 1
getrange

Sheets("Sheet1").Range("A2:g2").Copy



Sheets(Sheetname).Range(InsertRange).PasteSpecial
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets(Sheetname).Range(DTETMEInsertRange).Offset(0,
7).Value = Date
Sheets(Sheetname).Range(DTETMEInsertRange).Offset(0,
8).Value = time



ZeroScan = True

Else
Setnewtime
End If

Else
ZeroScan = False
Setnewtime
End If
End If

Loop

End Sub







"Thomas Lutz" wrote:

> A DDE Link should not cause any problems in an Excel spreadsheet as
> long as the links are implemented correctly. It is more likely that
> the problem is in whatever code is running every second. You may want
> to throw in an error handler to record all the errors so that you can
> track down what is going wrong.
> A better way to do things might be to use the Excel SetLinkOnData
> method to monitor the DDE data and trigger the macro that you are
> currently triggering with a timer. The SetLinkOnData method lets you
> configure a VBA subroutine to run automatically whenever data from a
> DDE link changes. Using this approach, you would never miss a single
> data value. With a timer taking a snapshot of the data every second,
> you could easily miss data as well as record redundant data.
>
>
> On Wed, 18 Jul 2007 11:58:00 -0700, Elceller in distress
> <(E-Mail Removed)> wrote:
>
> >In other words I know what the equipment was doing every second
> >during a 7 hour shift. The program seems to work fine when I test it in the
> >office, without the link and without letting it run 7 hours. When I leave it
> >running on the machine the program crashes, I have not seen the error that
> >comes up.
> >
> >Will a DDE link cause any type of error that can stop the program from
> >running?
> >Is there a way to program around DDE errors?
> >
> >This is the only program running on this computer can windows cause it to
> >crash in any way?

>

 
Reply With Quote
 
gimme_this_gimme_that@yahoo.com
Guest
Posts: n/a
 
      24th Jul 2007
Insert a DoEvents statement into your loop so you don't tie down the
operating system.

 
Reply With Quote
 
=?Utf-8?B?RWxjZWxsZXIgaW4gZGlzdHJlc3M=?=
Guest
Posts: n/a
 
      25th Jul 2007
Thanks, what about error handling

"(E-Mail Removed)" wrote:

> Insert a DoEvents statement into your loop so you don't tie down the
> operating system.
>
>

 
Reply With Quote
 
=?Utf-8?B?RWxjZWxsZXIgaW4gZGlzdHJlc3M=?=
Guest
Posts: n/a
 
      25th Jul 2007
I think I figured out the problem, the laptop that I was using was set up to
cut off the hard drive after 45 minutes. It seems to work fine now. Thanks
for your help.

"(E-Mail Removed)" wrote:

> Insert a DoEvents statement into your loop so you don't tie down the
> operating system.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tables: Appending Data, Link or Not to Link, That's My Question... MJ Microsoft Access 6 1st May 2010 01:57 PM
DATA LOGGING Clive Microsoft Excel Programming 0 30th Mar 2009 01:22 PM
Can I link a signature file to a profile without logging off the . =?Utf-8?B?SmVycnlDLVRyYWRlcklU?= Microsoft Outlook Discussion 1 11th Feb 2005 09:40 PM
Logging Into AD via WAN Link Sean Microsoft Windows 2000 Active Directory 3 1st Oct 2004 05:39 AM
Logging on when WAN link is down Pacman Microsoft Windows 2000 Active Directory 4 25th Mar 2004 03:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:35 AM.