First I must admit that when I signed up for forum I indicated that I am a programer...well that is a strech at best I am an end user who has cobbled some code together..
We have an application that links a name/address data base with word to create correspondence.
Orginal application developed years ago as VBA front end and Word Basic Macros in Word, transfered to VBA front end with Access 2000 and Word Macros changed to VBA & Office 2000.
Now as office is getting ready to go to Office 2003 I find that the application does not work with Office 2003. Program is set up to query some basic info from user, then goes out with a DDE command to extract data from database for Word to use. Do I need to dump the DDE and use GetObject?? I am just end user who has put together this correspondence system and don't want to go back to creating documents from scratch.
When try to run get error that DDEINITIATE is failing
Is this related to DDE commands being in a different reference in Office 2003 and Office 2000?
Here is this code we have been using:
Private Sub Generate_Click()
If Forms![WHEAT]![Template] <> "" And Forms![WHEAT]![Names] <> "" Then
Dim Channel As Long
Dim q As String * 1
Dim x As Integer
q$ = Chr$(34)
DoCmd.RunSQL "Update Distinctrow DDE Set DDE.ArptID = " + q$ + Forms![WHEAT]![AirportID] + q$ + ", DDE.RecNum = " + Forms![WHEAT]![Names] + " Where ((DDE.ID=1));"
On Error GoTo ErrorTrap ' if the DDEInitiate fails Error Trap will start Word
Channel = DDEInitiate("Winword", "System")
' the next line runs a macro in MACLIB.DOT that "Restores" the document
' window. This makes the app name on the title bar become "Microsoft Word"
' and that Makes the AppActive command easier to implement. Otherwise you have
' to go through permutations to figure out what is displayed in the Word
' Title Bar. the next 3 lines had been taken out of play put them back to see
'if this helps the appactivate errors that lead to opening a hundred docs or more dj 6/07
DDEExecute Channel, "[FileNew]"
DDEExecute Channel, "[ToolsMacro .Name = " + q$ + "DocRestore" + q$ + ", .Run]"
DDEExecute Channel, "[DocClose 2]"
' Dim appWord As Word.Application
'On Error Resume Next
' Set appWord = GetObject(, "Word.Application")
' If Err.Number <> 0 Then
' Set appWd = CreateObject("Word.Application")
' appWord.Visible = True
' End If
AppActivate "Microsoft Word"
' Hard coding the path for each temlate (rnj 2/14/00)
DDEExecute Channel, "[FileNew .Template = " + q$ + "f:\wheatvb\" + Template + q$ + "]"
'DDEExecute Channel, "[FileNew .Template = " + q$ + CurDir + "\" + Template + q$ + "]"
DDETerminate Channel
GoTo EndSub
We have an application that links a name/address data base with word to create correspondence.
Orginal application developed years ago as VBA front end and Word Basic Macros in Word, transfered to VBA front end with Access 2000 and Word Macros changed to VBA & Office 2000.
Now as office is getting ready to go to Office 2003 I find that the application does not work with Office 2003. Program is set up to query some basic info from user, then goes out with a DDE command to extract data from database for Word to use. Do I need to dump the DDE and use GetObject?? I am just end user who has put together this correspondence system and don't want to go back to creating documents from scratch.
When try to run get error that DDEINITIATE is failing
Is this related to DDE commands being in a different reference in Office 2003 and Office 2000?
Here is this code we have been using:
Private Sub Generate_Click()
If Forms![WHEAT]![Template] <> "" And Forms![WHEAT]![Names] <> "" Then
Dim Channel As Long
Dim q As String * 1
Dim x As Integer
q$ = Chr$(34)
DoCmd.RunSQL "Update Distinctrow DDE Set DDE.ArptID = " + q$ + Forms![WHEAT]![AirportID] + q$ + ", DDE.RecNum = " + Forms![WHEAT]![Names] + " Where ((DDE.ID=1));"
On Error GoTo ErrorTrap ' if the DDEInitiate fails Error Trap will start Word
Channel = DDEInitiate("Winword", "System")
' the next line runs a macro in MACLIB.DOT that "Restores" the document
' window. This makes the app name on the title bar become "Microsoft Word"
' and that Makes the AppActive command easier to implement. Otherwise you have
' to go through permutations to figure out what is displayed in the Word
' Title Bar. the next 3 lines had been taken out of play put them back to see
'if this helps the appactivate errors that lead to opening a hundred docs or more dj 6/07
DDEExecute Channel, "[FileNew]"
DDEExecute Channel, "[ToolsMacro .Name = " + q$ + "DocRestore" + q$ + ", .Run]"
DDEExecute Channel, "[DocClose 2]"
' Dim appWord As Word.Application
'On Error Resume Next
' Set appWord = GetObject(, "Word.Application")
' If Err.Number <> 0 Then
' Set appWd = CreateObject("Word.Application")
' appWord.Visible = True
' End If
AppActivate "Microsoft Word"
' Hard coding the path for each temlate (rnj 2/14/00)
DDEExecute Channel, "[FileNew .Template = " + q$ + "f:\wheatvb\" + Template + q$ + "]"
'DDEExecute Channel, "[FileNew .Template = " + q$ + CurDir + "\" + Template + q$ + "]"
DDETerminate Channel
GoTo EndSub