Firstly, I am not a VFP programmer, so what I'm doing wrong is probably something simple.
I'm trying to extract some documents out of general fields in a VFP 9 database. I have a way of doing this by effectively copying and pasting the field into Word and then saving the Word document off to disk.
I have this all working inside the foxpro development environment in a .prg file.
Here's the guts of my code (most of which was copied from a Microsoft Support question):
DO WHILE NOT EOF()
IF EMPTY(tnoteole) then
SKIP
LOOP
ENDIF
KEYBOARD "{ctrl+c} {ctrl+w}"
MODIFY GENERAL tnoteole
TRY
.EditPaste
CATCH
ENDTRY
.InsertPara
filename = Path + ALLTRIM(STR(recnum)) + ".doc"
.FileSaveAs(filename)
.EditSelectAll
.EditClear
SKIP
recnum = recnum + 1
ENDDO
My problem is that when I run this from inside the development environment it works fine, and the general field window flashes up on the screen and it gets pasted into Word, etc. But when I try running this from a complied exe (the process is triggered by the user clicking a button on a form - I have that much working - though I'd actually like it to be a batch job, with no user interaction required) Word opens, but that's as far as it gets. The general field doesn't flash up on the screen, and basically it just waits for ever.
(Oh and in case you're wondering about the nasty try/catch thing, I found some exception with Word when pasting some fields, but the try/catch works fine in the dev. environment, so I don't think that's the cause of my problems.)
So, how can I make this work? I'm kinda feeling my way around in the darkness of foxpro.
Please help! :)
Thanks,
Craig