From: Trevor Smith on 6 Feb 2007 18:18 Geoff The documents are are in rtf format. The process goes something like this: From within the VO app, the user selects a new document to send to a customer. These documents are normally based on Templates. Tokens can be inserted into the document in the form of [[USERFIRSTNAME]] Text form fields can also be used with a bookmark relating to a database field - userlastname for example. If it is a text field, the default text can be set to [[USERLASTNAME]]. The VO app creates the documents and parses it to populate any fields and tokens with data from the database. The document is then opened in Word (or other word processor) and presented to the user for editing. When the user has finished editing the document and saves it, the VO app parses the document again to see if any of the database related text fields have been updated. If any changes are found, the user is given the opportunity to save the new data back to the database. A similar process takes place if the document is later opened for editing except that the parsing only happens when the document is saved. As I say, this is all done in Rich Text Format and is very fast. However, I found that if the user has Outlook running in the background then the app would not wait for Word to finish and starts the second parse immediately. I try John's suggestion and include a check on the file time in the loop that is waiting for Word to finish. I did think about using the XML output from Word or OpenOffice but it would take (quite) a while for me to run up to speed with that and I already had a solution using Rich Text. It was just that Outlook seemed to be getting in the way. Trevor G Schaller wrote: > Trevor, > > This won't help you directly but what you are doing is always going to > cause problems because of the existing instance of Word on the machine. > There is benefit to these kinds of processes to use the XML version of > MS Office 2003 or use MS Office 2007. Here you can open your word doc > without having to load or run MS Word itself. Because the doc is in XML > format you can now read data directly from fields using an XML parser or > just simply text parse the doc. > > We have server processes which construct word docs on the server where > MS Office is not installed (think websites also). This is great for > standard letters and so on. I know this doesn't help this situation but > for those thinking of implementing this kind of technology, it bears > value thinking along these lines. > > Geoff > > > "Trevor Smith" <t.evs.mailbox(a)googlemail.)om> wrote in message > news:eq9r86$5bv$1(a)news.datemas.de: > >> I am using ShellExecuteEx to open up a Word form and then when the user >> closes the document I examine the form and retrieve data from some of >> the fields to put into a database. This works well except when the user >> has Outlook running at the same time and then the program doesn't wait >> for Word to finish and drops straight through to the UpdateCheck routine. >> >> Is there any way to prevent this other than getting the user to close >> Outlook? >> >> The code goes like this: >> >> // open the doc in Word >> lpShellInfo.cbSize := _SizeOf( _winShellExecuteInfo ) >> lpShellInfo.hwnd := self:Handle() >> lpShellInfo.lpVerb := String2Psz("open") >> lpShellInfo.lpFile := String2Psz( cFile ) >> lpShellInfo.nShow := SW_ShowNormal >> lpShellInfo.fMask := SEE_MASK_NOCLOSEPROCESS >> >> if ShellExecuteEx( @lpShellInfo ) >> hProc := lpShellInfo.hProcess >> GetExitCodeProcess( hProc, @lpExitCode ) >> lRunning := ( lpExitCode == STILL_ACTIVE ) >> while lRunning >> GetExitCodeProcess( hProc, @lpExitCode ) >> lRunning := ( lpExitCode == STILL_ACTIVE ) >> Yield() >> end >> >> // see if the user wants to retrieve any fields from the // saved doc >> oUC := UpdateCheck{self} >> oUC:File := cFile >> oUC:Show() >> end >> >> Thanks >> Trevor >
From: Trevor Smith on 6 Feb 2007 18:18 Thanks John, that sounds like a simple solution, I'll try it tomorrow. Trevor John Martens wrote: > Trevor, > > Couln't you check with your own routine AND check until data-time of the > file has been chenged ? > Probably the date-time of the file will only change if the user closes > the doc. > > John > > > Trevor Smith schreef: >> I am using ShellExecuteEx to open up a Word form and then when the >> user closes the document I examine the form and retrieve data from >> some of the fields to put into a database. This works well except when >> the user has Outlook running at the same time and then the program >> doesn't wait for Word to finish and drops straight through to the >> UpdateCheck routine. >> >> Is there any way to prevent this other than getting the user to close >> Outlook? >> >> The code goes like this: >> >> // open the doc in Word >> lpShellInfo.cbSize := _SizeOf( _winShellExecuteInfo ) >> lpShellInfo.hwnd := self:Handle() >> lpShellInfo.lpVerb := String2Psz("open") >> lpShellInfo.lpFile := String2Psz( cFile ) >> lpShellInfo.nShow := SW_ShowNormal >> lpShellInfo.fMask := SEE_MASK_NOCLOSEPROCESS >> >> if ShellExecuteEx( @lpShellInfo ) >> hProc := lpShellInfo.hProcess >> GetExitCodeProcess( hProc, @lpExitCode ) >> lRunning := ( lpExitCode == STILL_ACTIVE ) >> while lRunning >> GetExitCodeProcess( hProc, @lpExitCode ) >> lRunning := ( lpExitCode == STILL_ACTIVE ) >> Yield() >> end >> // see if the user wants to retrieve any fields from >> the // saved doc >> oUC := UpdateCheck{self} >> oUC:File := cFile >> oUC:Show() >> end >> >> Thanks >> Trevor
From: Stephen Quinn on 6 Feb 2007 19:19 Trevor Wouldn't it be a better option to have the user do all the changes in your app/database and just generate either the .doc or a mail merge file (if doing the same .doc to multiple clients). No interaction with word or anything else then. HTH Steve
From: G Schaller on 6 Feb 2007 20:34 Trevor. I think your process is overly complex. I would agree with Steve's approach. Duncan McIntosh has used letter generators for years exactly like this (and they are in RTF too). But the XML option opens up far simpler and more flexible solutions. I realise you may not be able to capitalise on it now - I just mentioned it for the benefit of others considering something similar. Geoff "Trevor Smith" <t.evs.mailbox(a)googlemail.)om> wrote in message news:eqb2ab$im8$1(a)news.freedom2surf.net: > Geoff > > The documents are are in rtf format. The process goes something like this: > From within the VO app, the user selects a new document to send to a > customer. These documents are normally based on Templates. Tokens can be > inserted into the document in the form of [[USERFIRSTNAME]] Text form > fields can also be used with a bookmark relating to a database field - > userlastname for example. If it is a text field, the default text can be > set to [[USERLASTNAME]]. > > The VO app creates the documents and parses it to populate any fields > and tokens with data from the database. > > The document is then opened in Word (or other word processor) and > presented to the user for editing. > > When the user has finished editing the document and saves it, the VO app > parses the document again to see if any of the database related text > fields have been updated. If any changes are found, the user is given > the opportunity to save the new data back to the database. > > A similar process takes place if the document is later opened for > editing except that the parsing only happens when the document is saved. > > As I say, this is all done in Rich Text Format and is very fast. > However, I found that if the user has Outlook running in the background > then the app would not wait for Word to finish and starts the second > parse immediately. > > I try John's suggestion and include a check on the file time in the loop > that is waiting for Word to finish. > > I did think about using the XML output from Word or OpenOffice but it > would take (quite) a while for me to run up to speed with that and I > already had a solution using Rich Text. It was just that Outlook seemed > to be getting in the way. > > Trevor > > > G Schaller wrote: > > > Trevor, > > > > This won't help you directly but what you are doing is always going to > > cause problems because of the existing instance of Word on the machine. > > There is benefit to these kinds of processes to use the XML version of > > MS Office 2003 or use MS Office 2007. Here you can open your word doc > > without having to load or run MS Word itself. Because the doc is in XML > > format you can now read data directly from fields using an XML parser or > > just simply text parse the doc. > > > > We have server processes which construct word docs on the server where > > MS Office is not installed (think websites also). This is great for > > standard letters and so on. I know this doesn't help this situation but > > for those thinking of implementing this kind of technology, it bears > > value thinking along these lines. > > > > Geoff > > > > > > "Trevor Smith" <t.evs.mailbox(a)googlemail.)om> wrote in message > > news:eq9r86$5bv$1(a)news.datemas.de: > > > > >> I am using ShellExecuteEx to open up a Word form and then when the user > >> closes the document I examine the form and retrieve data from some of > >> the fields to put into a database. This works well except when the user > >> has Outlook running at the same time and then the program doesn't wait > >> for Word to finish and drops straight through to the UpdateCheck routine. > >> > >> Is there any way to prevent this other than getting the user to close > >> Outlook? > >> > >> The code goes like this: > >> > >> // open the doc in Word > >> lpShellInfo.cbSize := _SizeOf( _winShellExecuteInfo ) > >> lpShellInfo.hwnd := self:Handle() > >> lpShellInfo.lpVerb := String2Psz("open") > >> lpShellInfo.lpFile := String2Psz( cFile ) > >> lpShellInfo.nShow := SW_ShowNormal > >> lpShellInfo.fMask := SEE_MASK_NOCLOSEPROCESS > >> > >> if ShellExecuteEx( @lpShellInfo ) > >> hProc := lpShellInfo.hProcess > >> GetExitCodeProcess( hProc, @lpExitCode ) > >> lRunning := ( lpExitCode == STILL_ACTIVE ) > >> while lRunning > >> GetExitCodeProcess( hProc, @lpExitCode ) > >> lRunning := ( lpExitCode == STILL_ACTIVE ) > >> Yield() > >> end > >> > >> // see if the user wants to retrieve any fields from the // saved doc > >> oUC := UpdateCheck{self} > >> oUC:File := cFile > >> oUC:Show() > >> end > >> > >> Thanks > >> Trevor > > >
From: Trevor Smith on 7 Feb 2007 08:00 Gary Stark wrote: > Trevor > > Trevor Smith wrote: >> I am using ShellExecuteEx to open up a Word form and then when the >> user closes the document I examine the form and retrieve data from >> some of the fields to put into a database. This works well except when >> the user has Outlook running at the same time and then the program >> doesn't wait for Word to finish and drops straight through to the >> UpdateCheck routine. > > If I'm understanding you correctly, then your application isn't actually > finding the Word application's Window, or else it thinks that Word has > finished before that actually is the case. > > This sounds to me as if you're not getting the correct process handle, > or that Outbreak is somehow interrupting the process flow and forcing > you to be given the incorrect handle. > > Have you examined the values that you're being returned when Outbreak is > also running? I'd start by examining that aspect, and try to understand > why you're unable to correctly monitor the process. > > When you have a handle on what's happening to your handles, you can then > handle the problem in your own handler. :) > Gary You are correct that's the problem, lpShellInfo.hProcess returns a NULL_PTR when Outlook is running. if ShellExecuteEx( @lpShellInfo ) hProc := lpShellInfo.hProcess Using Process Explorer I can see Word running as a service if Outlook is running, perhaps this is why I can't get the handle! Trevor
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Wildseek doesn't work with memo-fields Next: Using C# COM object in VO |