Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default DDE limitation?

Hi all,

I've written a function (DDEsend, see below) to send some worksheet
cells to another application. DDEsend opens a DDE channel, loops
through the cells sending the value if valid and then closes the
channel. The function returns the number of items sent and only does
the DDEpoke if a commandbar button is down (on/off control). The
function works absolutely perfectly if it is called from another
command button or by running this function from the VB editor:

Function FakeIt()

Set QuickRange = ActiveSheet.Range("AB12:AB19011")
Sent = DDEsend(QuickRange)
Debug.Print Sent

End Function

The value printed is exactly what I expect and the data arrives at my
target app. All very nice.

However, if I call the function from a cell everything works except
the DDE. Here's what is in the cell:

=DDEsend(AB12:AB19011)

The value displayed in the cell is exactly what I expect and exactly
the same value as in the immediate window from FakeIt. But nothing
arrives by DDE. I want to call the function from a cell so that the
data is updated on change.

Here's the function:

Function DDEsend(SendRange)
Dim ChannelNumber As Long
Dim CellToPoke As Variant
Dim IDToPoke As Variant

' Setup handle to command bar button
Set ButtonHandle = CommandBars("Triguard").Controls(8)

' Only do DDE send if button is down
If ButtonHandle.State = msoButtonDown Then

' Setup DDE channel
ChannelNumber = Application.DDEInitiate( _
app:="WWserver", topic:="AUG_OUT")

' Counters
SentCells = 0
SkippedCells = 0

For Each Cell In SendRange
Set CellToPoke = Cell
If Not (Cell = "") Then
' Is it a discrete or a register
TypeToPoke = Cell.Offset(0, -17)

' Check the value is legal
Valid = CheckBounds(TypeToPoke, Cell)

If Valid Then
IDToPoke = Left(TypeToPoke, 1) & _
LTrim(Str(Cell.Offset(0, -18)))
' Send it
Application.DDEpoke _
ChannelNumber, IDToPoke, CellToPoke
SentCells = SentCells + 1
Else
SkippedCells = SkippedCells + 1
End If
End If
Next Cell

Application.DDETerminate ChannelNumber

If SkippedCells 0 Then
PromptText = "Sent " & SentCells & " to WWServer. " & _
SkippedCells & " not sent due to invalid values."
Response = MsgBox(PromptText, vbOKOnly, _
"Wonderware stimulation")
End If

DDEsend = SentCells
Else
DDEsend = "Off"
End If

End Function

If I step through the code I can't see any differences in the data
types and values using the two call methods. What have I missed?
Have I hit a limitation of DDE, Excel or VBA?

Thanks in advance

Julian

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Row Limitation in SUMPRODUCT Stephen Excel Worksheet Functions 3 October 2nd 07 09:30 PM
Row Limitation Atom Smasher Excel Discussion (Misc queries) 4 July 17th 06 07:59 PM
Way around row limitation mrwawa Excel Discussion (Misc queries) 4 June 29th 06 08:46 PM
IF Limitation? Michael168[_88_] Excel Programming 3 June 7th 04 06:42 PM
Limitation Jase Excel Programming 1 December 3rd 03 12:35 AM


All times are GMT +1. The time now is 10:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"