WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DDE

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to create new MS Word8 document with DDE commands

Keywords:     DDE

Question:

Can you give me a code sample on how to create a new MS Word document using DDE commands?

Answer:

Creating a new document with DDE may be tough. I say that because while I figured out how to update and delete records in an MS Access database using the WIL DDE functions, I was never able to figure out how to create a new record.

I haven't used DDE with Word, but here's some of my DDE code for selecting and updating Access. But don't try to SQL INSERT anything unless you want more frustration. :)

        ; to select a record

        SQLstmt='SELECT MAX(Root) FROM Root_URL;'
        channel = DDEInitiate("MSAccess","%MDB%;SQL") ; open DDE channel
        if channel > 0
           if DDEPoke(channel,"SQLtext",SQLstmt)
              maxroot = DDERequest(channel,"DATA")
           else
              Message(nm,"DDEPoke() for maximum root failed")
              Exit
           endif
           
           DDETerminate(channel) ; close DDE channel
        else
           Message(nm,"DDEInitiate() failed")
           Exit
        endif

        ; to update a record

        channel=DDEInitiate("MSAccess","%MDB%;SQL")
        if channel > 0
           SQLstmt='UPDATE Root_URL SET LastScan="%today%"'
           SQLstmt='%SQLstmt% WHERE Root="%root%";'
           
           if DDEExecute(channel,'[RunSQL %SQLstmt%]')==@FALSE
	      FileWrite(ft,`UPDATE failed:%@CRLF%%SQLstmt%`)
	      Message(nm,"UPDATE failed")
	      Exit
	   endif
	   
	   DDETerminate(channel)
	endif

	; to insert a record  -- many problems...
	; Ask God to do it :)

Article ID:   W12807
Filename:   DDE Code to Update Access.txt
File Created: 1999:04:15:16:49:46
Last Updated: 1999:04:15:16:49:46