Get Error #13 when trying to use DDEINITIATE any ideas?

K

KCFAAENGR

Am trying to link Access Data Base with Word Application want to pass data
from Access to Word. Have application working under Access 2000 now as we are
getting ready to upgrade to Access 2003 the line of code with DDEINITIATE
gives me a typemismatch error#13

Dim cNum As Long
Dim q As String * 1
Dim x As Integer
Dim strSQL As String

q$ = Chr$(34)

DoCmd.RunSQL "Update Distinctrow DDE SET DDE.ArptID = " + q$ +
Forms![WHEAT]![AirportID] + q$ + ", DDE.RecNum = " + Forms![WHEAT]![Names] +
", DDE.Template = " + q$ + Forms![WHEAT]![Template] + q$ + " Where
((DDE.ID=1));"
MsgBox "MSGBOX 1 Made it past DoCmd.RunSQL"


Dim appWord As Word.Application
MsgBox "MSGBOX 2 Made it past AppWord"
On Error Resume Next
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set appWord = CreateObject("Word.Application")
If Err.Number <> 0 Then
Set appWord = CreateObject("Word.application")
appWord.Visible = True
End If
End If
MsgBox "MSG BOX 3 made it past check to see if word running"
'appword.filenew.template (

On Error GoTo ErrorTrap
MsgBox "MSGBOX 4 Made it Past On Error GoTo ErrorTrap"
cNum = DDEInitiate("WINWORD", "SYSTEM")
MsgBox "cNum = " + cNum
'DDEExecute cNum, "[FileNew]"
'DDEExecute cNum, "[ToolsMacro .Name = " + q$ + "DocRestore" + q$ + ",
..Run]"
'DDEExecute cNum, "[DocClose 2]"
'starting up new word document based upon template selected by user...
DDEExecute cNum, "[FileNew .Template = " + q$ + "f:\wheatvb\" + Template
+ q$ + "]"
DDETerminate cNum
DDETerminateAll
MsgBox " MSGBOX 5A: Made it through DDE"
GoTo EndSub
DJ
 
D

Douglas J. Steele

Realistically, DDE is extremely old technology that probably shouldn't be
used anymore.

Automation is the appropriate way to communicate between Access and Word.
 
D

David W. Fenton

Realistically, DDE is extremely old technology that probably
shouldn't be used anymore.

Automation is the appropriate way to communicate between Access
and Word.

Some would say COM is outdated nowadays, too.

(I wouldn't be among them, of course)
 
R

Robert Morley

While Doug is absolutely correct that DDE is significantly outdated, I
believe the problem may be your declaration of cNum as a Long. DDEInitiate
returns a Variant. Try changing it and see what you get.


Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top