Excel Macro Strings
Sub TMP_InstantLog()
Dim PLCMonth, PLCDay, PLCYear, PLCDate As String
'''''
'Channel = DDEInitiate("DSData", "TMP_DataRetrieve")
PLCMonth = 12 ' DDERequest(Channel, "V30145:B")
PLCDay = 5 'DDERequest(Channel, "V30146:B")
PLCYear = 3 'DDERequest(Channel, "V30147:B")
'DDETerminate Channel
'''''
PLCDate = PLCMonth & "/" & PLCDay & "/0" & PLCYear
curr_tmp = 3
Worksheets("Sheet1").Cells(curr_tmp, 18).Value = DateValue(PLCDate)
End Sub
worked fine for me - there must be something screwed up in your data.
try
msg = "-" & PLCMonth & "<-" & typename(PLCMonth) & vbNewline & _
"- & PLCDay & "<-" & typename(PLCDay) & vbNewline & _
"- & PLCYear & "<-" & typename(PLCYear)
msgbox msg
before PCLDate = . . .
--
Regards,
Tom Ogilvy
"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.
|