Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to know if the Word is closed?
Message
De
23/11/2004 13:08:09
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/11/2004 12:37:32
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00963921
Message ID:
00963946
Vues:
7
>I create & run MS Word MailMerge, but I don't want the user go back to VFP until he/she closed the Word Window. Untill now I use Cetin's MailMerge Class to find the window of teh MaiMerged Letters & go in a DO WHILE loop. But now some of my users have a MS Office builder in different languages so tha caption of the Form Letter Document vary due to language. So may question is How to know if the user closed the Word Window?
>
>
>myWord = CreateObject("Word.Application")
>**** do a Mail merge
>**** close all additional Word Windows as Main Document & DataSource
>DO WHILE FindWindow(0, "MicroSoft Word - Form Letters") # 0 && But "that caption now is varying :o(((
>  DO EVENTS
>ENDDO
>
Boris,
Ask caption to word.
Side note: FindWindow('OpusApp',0) searches by class instead of caption. Also after setting oWord.Visible = .t., oWord.Activate you could get its handle:
gHwndWord = GetForegroundWindow()

And yet another piece of code:
*...
If llToPrinter
  oWatcher = CreateObject('myTimer', oWordDocument)
Else
  oWatcher = CreateObject('myTimer2', oWordDocument)
EndIf
*...

Define Class myTimer As Timer
 Interval = 1000
 oWord = .null.
 
 Procedure init
 Lparameters toWord
 this.oWord = toWord
 endproc
 
  Procedure Timer
    With this.oWord
       If .BackgroundPrintingStatus > 0 && Wait printing to finish
        Return
      Endif
      For Each oDoc In .Documents
        oDoc.Close(wdDoNotSaveChanges)
      Endfor
      oDoc = .Null.
      .Quit(wdDoNotSaveChanges)
    EndWith
    this.Enabled = .F.
    Clear Events
  Endproc
Enddefine

Define Class myTimer2 As Timer
 Interval = 1000
 oWord = .null.
 
 Procedure init
 Lparameters toWord
 this.oWord = toWord
 endproc

  Procedure Timer
    If Type('this.oWord.Visible') = 'L' and this.oWord.Visible
        Return
    endif   
    this.Enabled = .F.
    Clear Events
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform