Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Automation
Message
From
01/05/2023 15:27:51
 
 
To
01/05/2023 14:29:02
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Miscellaneous
Thread ID:
01686524
Message ID:
01686530
Views:
51
Thank you Luis!

I extracted the code into a little test program that looks like:

#INCLUDE D:\INCLUDES\MSWORD.H && Konstantendefinitionen für Word
lcVorlag = 'd:\u09\vorlagen\DE_OptOut_Proprietors.dotx'
oWord = NULL
oWord = CREATEOBJECT('Word.Application')
? oword.Documents.count
oWord.Visible = .T.
oWord.WindowState = wdWindowStateNormal
DECLARE INTEGER FindWindow IN user32 STRING lpClassName, STRING lpWindowName
DECLARE INTEGER BringWindowToTop IN user32 INTEGER hWindow
DECLARE Long ShowWindow In Win32API Long, Long
lhWnd = FindWindow(Null, "Word")
IF lhWnd = 0 && Nicht gefunden
* Word kann nicht in Vordergrund geholt werden, muss manuell gemacht
* werden. Ohne Fehlermeldung zurück.
lnRetVal = 0
RETURN lnRetVal
ENDIF && lhWnd = 0 && Nicht gefunden
BringWindowToTop(lhWnd)
ShowWindow(lhWnd, 1)
ShowWindow(lhWnd, 5)

oword.Documents.Add(lcVorlag)
oWord.ActiveDocument.MailMerge.Execute()

lcVorlDok = 'Dokument'
lcVerzName = oWord.ActiveDocument.Name
lnFenster = oWord.ActiveDocument.ActiveWindow.Index
? 'lcVorlDok: ' + lcVorlDok
? 'lcVerzName: ' + lcVerzName
? 'lnFenster: ' + ALLTRIM(STR(lnFenster))

IF lcVerzName = lcVorlDok && Actives Fenster enthält Vorlage
oWord.ActiveDocument.Close(0)
ELSE && Wir stehen auf dem erzeugten Dokument.
IF lnFenster = 1
oWord.Windows(2).Close(0)
ELSE
oWord.Windows(1).Close(0)
ENDIF && lnFenster = 1
ENDIF && lcVorlDok = lcVerzName

WAIT WINDOW 'Weiter mit Taste'
oword.documents.Close(0) && Schließen OHNE speichern
oWord.Quit

Please let me know, if I should translate my comments.

Gerhard Schmidbauer

>Hi Gerhard:
>
>In both cases (development and production) are you using the same logged-user? Could you show us part of your code? More important is how you generate the filenames and how you perform the merge.
>
>Luis
>
>
>>Thank you Tore,
>>
>>I do use full pathes already. Seems to be something else.
>>
>>Gerhard Schmidbauer
>>
Gerhard Schmidbauer
URANUS Software GmbH
Previous
Reply
Map
View

Click here to load this message in the networking platform