|
DDEPoke的语法如下,
DDEPoke channel%, item$, data$
我创建了以下脚本,可是无法使用DDEPoke向word中写入testtext="Hello, world."
不知道什么原因?
还请高手能帮忙一下。
Sub main
Dim channel as Integer
Dim appname as String
Dim topic as String
Dim testtext as String
Dim item as String
Dim pcommand as String
Dim msgtext as String
Dim answer as String
Dim x as Integer
Dim path as String
appname="WinWord"
path="c:\msoffice\winword\"
topic="System"
item="Page1"
testtext="Hello, world."
On Error Goto Errhandler
x=Shell(path & appname & ".EXE")
channel = DDEInitiate(appname, topic)
If channel=0 then
MsgBox "Unable to open Word."
Exit Sub
End If
DDEPoke channel, item, testtext
pcommand="[FileSaveAs .Name = " & Chr$(34) & "C:\TEMP001" & Chr$(34) & "]"
DDEExecute channel, pcommand
pcommand="[FileClose]"
DDEExecute channel, pcommand
msgtext="The text: " & testtext & " saved to C:\TEMP001." & Chr$(13)
msgtext=msgtext & Chr$(13) & "Delete? (Y/N)"
answer=InputBox(msgtext)
If answer="Y" or answer="y" then
Kill "C:\TEMP001.doc"
End If
DDETerminate channel
Exit Sub
Errhandler:
If Err<>0 then
MsgBox "DDE Access failed."
End If
End Sub
[ 本帖最后由 ilovejolly 于 2005-12-20 09:36 编辑 ] |
|