Hello,
I am trying to make a very simple aplication :
Open a RTF-file with word.exe
The user can edit this file and MUST save or end word
First i downloaded tWord.zip from patrick's site . I can compile , but i can not make a working sample as described.
Any example is welcome
Frank
Invoking "Word.Application" wityh ole
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Invoking "Word.Application" wityh ole
To just open a file use
EMG
Code: Select all
SHELLEXECUTE( 0, 0, "yourfilename", 0, 0, 1 )
-
- Posts: 142
- Joined: Sun Oct 09, 2005 10:59 am
Enrico,
yes , i know , i use this at the moment.
Only , i have problems , probably because i am working in MDI envirronnement , and it is not clear when word.exe receive focus , it can also be later in the program. Not closing the text editor give also problems.
So , i tryed to use ole , hoping to avoid this problems
After the shellexecute i had to place a msginfo. Working on XP , this give no problems , but at the client , the msginfo appears before the text editor
Has anyone a better solution ?
Frank
yes , i know , i use this at the moment.
Only , i have problems , probably because i am working in MDI envirronnement , and it is not clear when word.exe receive focus , it can also be later in the program. Not closing the text editor give also problems.
So , i tryed to use ole , hoping to avoid this problems
Code: Select all
function MemoEdit( cText)
LOCAL hWnd
Memowrit("C:\TEMP\efkes.rtf",cText)
Shellexecute(0 ,0 , "C:\TEMP\efkes.rtf" ,0 ,0 , 1)
hWnd := FINDWND( "EFKES.RTF" )
? "Attention , continue only when the text file is corectly closen"
DO WHIL .T.
hWnd := FINDWND( "EFKES.RTF" )
IF !EMPTY( hWnd )
? " rtf-file not closed : " + CRLF + GETWINDOWTEXT( hWnd )
? "The program closes it "
SENDMESSAGE( hWnd, 16 )
//CloseWindow(hWnd)
ELSE
EXIT
END
END
cText := Memoread("C:\TEMP\efkes.rtf" )
Has anyone a better solution ?
Frank
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Frank,
Try this:
Try this:
Code: Select all
do while ( hWnd := FINDWND( "EFKES.RTF" ) ) == 0
SysRefresh()
end
? "Attention , continue only when the text file is corectly closen"
-
- Posts: 142
- Joined: Sun Oct 09, 2005 10:59 am
Antonio,
The client asked me to avoid the msginfo , but also when i add your code , this seems not to be possible
Now , i see very shortly the meginfo , and then is word activated.
Without the msginfo , i can return to the program without closing word , this gives problems in the next time the shellexecute is activated.
Any idea ?
Frank
The client asked me to avoid the msginfo , but also when i add your code , this seems not to be possible
Now , i see very shortly the meginfo , and then is word activated.
Without the msginfo , i can return to the program without closing word , this gives problems in the next time the shellexecute is activated.
Any idea ?
Frank
Frank
See this:
See this:
Code: Select all
...
OLEWORD97(oWndMain,"C:\TEMP\efkes.rtf")
...
FUNCTION OLEWORD97(oOLEWnd,cFName)
LOCAL oWnd, cWndName := cFileName(cFName) + " - Microsoft Word"
DEFINE WINDOW oWnd TITLE "FiveWin OLE Support" FROM 0, 0 TO 600, 800 PIXEL
oWord:=TOleAuto():New( "Word.Application" )
oWord:Documents:Open( cFName )
oWord:Visible := .t.
oWord:WindowState := 1
//oWord:PrintOut() // You need print?
oWord:End()
ACTIVATE WINDOW oWnd ON INIT (WinExec(cWndName), WinCapsule(oWnd,cWndName))
//VALID ( oWord:End(), .t. )
RETURN
Function WinCapsule(oWin,cWName)
local lCaptured, hIE
hIE := FindWindow(0,cWName)
lCaptured := ( hIE > 0 )
IF lCaptured
SetParent(hIE, oWin:hWnd)
SysRefresh()
ELSE
MsgRun('OLE not activated.')
ENDIF
return nil
Sorry
Its a very little modification
Its a very little modification
Code: Select all
FUNCTION OLEWORD97(oOLEWnd,cFName)
LOCAL oWnd, oWord, cWndName := cFileName(cFName) + " - Microsoft Word"
DEFINE WINDOW oWnd TITLE "FiveWin ActiveX Support" FROM 0, 0 TO 600, 800 PIXEL
oWord:=TOleAuto():New( "Word.Application" )
oWord:Documents:Open( cFName )
oWord:Visible := .t.
oWord:WindowState := 1
//oWord:PrintOut()
//oWord:End()
ACTIVATE WINDOW oWnd ON INIT (WinExec(cWndName), WinCapsule(oWnd,cWndName)) ;
VALID ( oWord:Quit(), oWord:End(), .t. )
Last edited by Rochinha on Mon Feb 19, 2007 3:28 pm, edited 1 time in total.
Is this better than using TWORD?
http://fivetechsoft.com/forums/viewtopi ... ight=tword
What do I need to INCLUDE to try the code you have included here?
http://fivetechsoft.com/forums/viewtopi ... ight=tword
What do I need to INCLUDE to try the code you have included here?
Many thanks
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)