Rudolfmdlt
12-31-2013, 05:15 AM
Hi All,
I need to pass a string from one application to another and execute based on that string. I just cannot get this to work in Access and am finally at my wits end!
I have the following code in Excel:
Sub DDETest()
Dim chanNum As Variant
chanNum = DDEInitiate("WinWord", "System")
DDEExecute chanNum, "[DDETesting.Test(5)]"
DDEExecute chanNum, "[DDETesting.Test2(""John"",""Doe"", 12)]"
DDETerminate chanNum
End Sub
And the following in Word in a module called DDETesting
Sub Test(iNum As Integer)
MsgBox "The value is: " & iNum
End Sub
Sub Test2(strFname As String, strLname As String, iNum As Integer)
MsgBox "The values are: " & strFname & "," & strLname & "," & iNum
End Sub
And it works. :)
Now, I have been busy for the last 2 days trying to port the Word side code to Access. :banghead:
In Excel,
Sub DDETest() Dim chanNum As Variant
chanNum = DDEInitiate("MSACCESS", "System")
DDEExecute chanNum, "[DDETesting.Test(5)]"
DDEExecute chanNum, "[DDETesting.Test2(""John"",""Doe"", 12)]"
DDETerminate chanNum
End Sub
In Access, in a module called DDETesting as well:
Option Compare Database
Sub Test(iNum As Integer)
MsgBox "The value is: " & iNum
End Sub
Sub Test2(strFname As String, strLname As String, iNum As Integer)
MsgBox "The values are: " & strFname & "," & strLname & "," & iNum
End Sub
When I execute the Excel code while pointing the DDE at Access, Access pops up with the error "Microsoft Access cannot find the object 'DDETesting.' "
I have tried almost a hundred permutations of DDETesting.Test(5), Test(5), Database1.DDETesting.Test(5) ect but I cannot get Access to execute my code.
The only time I can get Access to do anything is when I create Point-and-Click macro using the GUI editor. These Macros Access sees, but anything I write by hand seems to be invisible!?
I would really appreciate any help!
Thanks for your time,
Regards,
Rudolf
PS: I'm actually trying to do this using C++ and access, but after 2 days of failures I tried using just Office application to check whether it wasn't an environment issue, and exactly the same issue.
I'm using this HowTo for the Excel and Word testing: support.microsoft.com/kb/274284
I need to pass a string from one application to another and execute based on that string. I just cannot get this to work in Access and am finally at my wits end!
I have the following code in Excel:
Sub DDETest()
Dim chanNum As Variant
chanNum = DDEInitiate("WinWord", "System")
DDEExecute chanNum, "[DDETesting.Test(5)]"
DDEExecute chanNum, "[DDETesting.Test2(""John"",""Doe"", 12)]"
DDETerminate chanNum
End Sub
And the following in Word in a module called DDETesting
Sub Test(iNum As Integer)
MsgBox "The value is: " & iNum
End Sub
Sub Test2(strFname As String, strLname As String, iNum As Integer)
MsgBox "The values are: " & strFname & "," & strLname & "," & iNum
End Sub
And it works. :)
Now, I have been busy for the last 2 days trying to port the Word side code to Access. :banghead:
In Excel,
Sub DDETest() Dim chanNum As Variant
chanNum = DDEInitiate("MSACCESS", "System")
DDEExecute chanNum, "[DDETesting.Test(5)]"
DDEExecute chanNum, "[DDETesting.Test2(""John"",""Doe"", 12)]"
DDETerminate chanNum
End Sub
In Access, in a module called DDETesting as well:
Option Compare Database
Sub Test(iNum As Integer)
MsgBox "The value is: " & iNum
End Sub
Sub Test2(strFname As String, strLname As String, iNum As Integer)
MsgBox "The values are: " & strFname & "," & strLname & "," & iNum
End Sub
When I execute the Excel code while pointing the DDE at Access, Access pops up with the error "Microsoft Access cannot find the object 'DDETesting.' "
I have tried almost a hundred permutations of DDETesting.Test(5), Test(5), Database1.DDETesting.Test(5) ect but I cannot get Access to execute my code.
The only time I can get Access to do anything is when I create Point-and-Click macro using the GUI editor. These Macros Access sees, but anything I write by hand seems to be invisible!?
I would really appreciate any help!
Thanks for your time,
Regards,
Rudolf
PS: I'm actually trying to do this using C++ and access, but after 2 days of failures I tried using just Office application to check whether it wasn't an environment issue, and exactly the same issue.
I'm using this HowTo for the Excel and Word testing: support.microsoft.com/kb/274284