How can I exchange data between PB and WinWord (No OLE).

How can I send a data from PowerBuilder to WinWord in .DOC file. and from Winword to PowerBuilder. (please no OLE).
LVL 4
BhattiAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AFIConnect With a Mentor Commented:
Ok, my friend I made this little example to use Word with DDE.

//command button cb_1 (clicked!)
Long      ll_hwnd, ll_hchannel
String     ls_wserver = "WinWord"
Integer li_close


Run("winword.exe") //Word most be open

ll_hwnd = Handle(Parent) //Optional

ll_hchannel = OpenChannel(ls_wserver, "System", ll_hwnd)
If ll_hchannel = 0 Then
   MessageBox("Advertencia", "Servidor no encontrado.")
   Return
End If

ExecRemote("[FileNewDefault]", ll_hchannel, ll_hwnd)
ExecRemote("[Insert(~"Hola~")]", ll_hchannel, ll_hwnd)

li_close = CloseChannel(ll_hchannel, ll_hwnd)

If li_close <> 1 Then
   MessageBox("Error", "No se cerro el canal de comunicación")
End If

I use PB6.5 and MSWord 2000, to make this example.
0
 
AFICommented:
Hello, I know you don't want OLE but I use the OLE with good results and the object that PB not suport I add in a macro that is called inside my PB App.... Ok... sorry but I express my self better in spanish... Bien la otra solución es utilizar DDE (dynamic data exchange).... You can find this in Word Help (Visual Basic)

Códigos de campo: campos DDE y DDEAuto
{ DDE NombreAp NombreArchivo [LugarRef] }
{ DDEAUTO NombreAp NombreArchivo [LugarRef] }

Establece un vínculo de intercambio dinámico de datos (DDE) con un documento creado en otro programa basado en Windows. Si hay nueva información disponible en un documento vinculado, el campo DDE insertará la nueva información cuando se actualice. El campo DDEAUTO inserta automáticamente la información nueva en el momento en que esté disponible. Si Word no puede establecer el vínculo cuando intente actualizar un campo DDE o DDEAUTO, se conservará el resultado anterior.

Instrucción Explicación
NombreAp Nombre de otro programa que admita DDE.
"NombreArchivo" Nombre de un archivo u otro elemento reconocible por el programa NombreAp. Si la posición incluye un nombre de archivo largo con espacios, debe ir entre comillas. Reemplace las barras diagonales inversas por barras diagonales inversas dobles para indicar la ruta de acceso, por ejemplo:
"C:\\Mis documentos\\Manual.doc"
 
[LugarRef] Parte del archivo o elemento especificado, como por ejemplo un rango de celdas de una hoja de cálculo de Microsoft Excel o un marcador de un documento de Word.
0
 
BhattiAuthor Commented:
Dear AFI,

I have no problem with OLE. But I am searching a solution without OLE. If you have any idea please let me know.


THANKS


Best regards

Bhatti
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
AFICommented:
Hello Bhatti, the following code you can find it in PB Help, is about Excel but is similar to Word... If I made an example in Word I will send you....

These statements open a channel to the active spreadsheet REGION.XLS in Microsoft Excel and set handle to the handle to the channel.

long handle

handle = OpenChannel("Excel", "REGION.XLS")

The following example opens a DDE channel to Excel and requests data from three spreadsheet cells. In the PowerBuilder application, the data is stored in the string array s_regiondata. The client window for the DDE conversation is w_ddewin.

long handle

string s_regiondata[3]

handle = OpenChannel("Excel", "REGION.XLS",  &

Handle(w_ddewin))
GetRemote("R1C2", s_regiondata[1], handle,  &
          Handle(w_ddewin))
GetRemote("R1C3", s_regiondata[2], handle,  &
          Handle(w_ddewin))
GetRemote("R1C4", s_regiondata[3], handle,  &
          Handle(w_ddewin))
CloseChannel(handle, Handle(w_ddewin))
0
 
BhattiAuthor Commented:
How to do in EXCEL I know. I am searching solution with WIN-World

Best Regards


Bhatti
0
 
BhattiAuthor Commented:
I shall try and let you know soon.


Best regards


Bhatti
0
 
BhattiAuthor Commented:
Thanks AFI.
0
All Courses

From novice to tech pro — start learning today.