View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Dan E[_2_] Dan E[_2_] is offline
external usenet poster
 
Posts: 102
Default Excel Macro Strings

Brandon,

I won't guarantee anything, but you can give this a try, I can't test it out
because unfortunately I don't have any PLC's though their is an RTU or two
kicking around here. I put in some CStr (Convert to string) statements
which may be of use.

Sub TMP_InstantLog()

Dim PLCMonth, PLCDay, PLCYear, PLCDate As String
'''''
Channel = DDEInitiate("DSData", "TMP_DataRetrieve")

PLCMonth = CStr(DDERequest(Channel, "V30145:B"))
PLCDay = CStr(DDERequest(Channel, "V30146:B"))
PLCYear = CStr(DDERequest(Channel, "V30147:B"))

DDETerminate Channel
'''''
PLCDate = CStr(PLCMonth & "/" & PLCDay & "/0" & PLCYear)
Worksheets("Sheet1").Cells(curr_TMP, 18).Value = DateValue
(PLCDate)

Dan E

"Brandon" wrote in message
...
Run-time error '13':
Type Mismatch


This is my code:

**********

Sub TMP_InstantLog()

Dim PLCMonth, PLCDay, PLCYear, PLCDate As String
'''''
Channel = DDEInitiate("DSData", "TMP_DataRetrieve")

PLCMonth = DDERequest(Channel, "V30145:B")
PLCDay = DDERequest(Channel, "V30146:B")
PLCYear = DDERequest(Channel, "V30147:B")

DDETerminate Channel
'''''
PLCDate = PLCMonth & "/" & PLCDay & "/0" & PLCYear
Worksheets("Sheet1").Cells(curr_TMP, 18).Value = DateValue
(PLCDate)

**********

When I retrieve the date values, they are all numbers,
not strings, and also-- the "/0" in the line that assigns
a value to PLCDate, the "0" is because when I retrieve
the year from the PLC (programmable logic controller), it
comes as 03 which becomes just '3'. I think it is just a
variable type inconsistency, like I am using numbers but
it is looking for a String.
Thanks for all the help you're giving, Dan E.