Question : DDE from MSAccess to MSExcel

Hi,
  I have wriiten a program in Access which is suppose to use dde to communicate with Excel. The code is as follows:

Function Testing()
Dim channel As Variant
channel = DDEInitiate("Microsoft Excel", "C:\a.xls")
DDEPoke channel, "R1C1", "Hello"
DDETerminateAll     ' Terminate all links.
End Function

The file in Excel "a.xls" is already opened.  Every time I try to execute this function, Access will prompt "Run-time error '282' MSAccess can't find the specified application and topic because it can't open the DDE channel...."

Please help. Thanks alot!

Answer : DDE from MSAccess to MSExcel

Hi,

Function XL_From_Access()
Dim MyXL As Object
Set MyXL = GetObject("c:\file.xls")
With MyXL.worksheets(1)
    .cells(1, 1).Value = "X"
End With
MyXL.Windows(1).Visible = True
MyXL.SaveAs "c:\file_bis.xls"
MyXL.Save
MyXL.Close
Set MyXL = Nothing
End Function

DS
Random Solutions  
 
programming4us programming4us