View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
CW[_3_] CW[_3_] is offline
external usenet poster
 
Posts: 1
Default Poking Excel data into a Word Documnet

I am trying to write a program in Excel that will work
with a Word document to create a letter with various
variables calculated in the excel workbook. I tried using
the DDE Initiate and Poke commands(I found these in a box
by John Walkenback - excel for win 95 power programing
with VBA) but it doesn't seem to work. Code I'm using is
below. Everytime I run it I first get a message box
saying "remote data not accessible, start application
WinWord.exe" I choose yes then get an error code 13, type
mismatch and the progam stops at the DDEInitiate line.


Sub Macro2()
'
' Macro2 Macro
' Macro recorded 11/13/2003 by James
'

IName = Sheets("sheet1").Range("b1")
ITitle = Sheets("sheet1").Range("b2")
Borrower = Sheets("sheet1").Range("b3")
Baddress = Sheets("sheet1").Range("b4")
BankName = Sheets("sheet1").Range("b5")
Sal = Sheets("sheet1").Range("b6")
BkAbrv = Sheets("sheet1").Range("b7")
BAbrv = Sheets("sheet1").Range("b8")
LoanType = Sheets("sheet1").Range("b9")
LoanAmt = Sheets("sheet1").Range("b10")

cfile = Application.GetSaveAsFilename & ".doc"
channel1 = DDEInitiate("WinWord.exe", cfile)

DDEPoke channel1, "IName", IName
DDEPoke channel1, "ITitle", ITitle
DDEPoke channel1, "Borrower", Borrower
DDEPoke channel1, "BAddress", Baddress
DDEPoke channel1, "BankName", BankName
DDEPoke channel1, "Sal", Sal
DDEPoke channel1, "BkAbrv", BkAbrv
DDEPoke channel1, "BAbrv", BAbrv

DDETerminate channel1

Application.ActivateMicrosoftApp xlMicrosoftWord


End Sub


It may be that I am running Office / excel 2000 but it
seems like there should be some way to pass information
from excel to word.

Can anyone help me??