Olaf,
hier der Code, ich habe das Problem ja bisher nur bei einem Kunden, bei allen anderen funktioniert das.
Code: Alles auswählen
FUNCTION WordFillANSHKA(cFile,cSaveAs,lPrint, lDruOrEdit,nCopies,lVorschau, nSchacht1, nSchacht2, nOrientation, cPrinter)
LOCAL oWord,oBM,oDoc, oDruckerSettings
local mess1 := LGTrans(('Cdb')->sprache,'0051001','Microsoft Word ist nicht installiert')
LOCAL mess1029 := LGTrans(('Cdb')->sprache,'0051029','nicht gefunden!')
LOCAL mess1030 := LGTrans(('Cdb')->sprache,'0051030','Datei:')
local lWordFinished := .f.
local i := 0
LOCAL nEvent := 0, mp1, mp2
LOCAL lBackground := .f.
LOCAL cOldPrinter
LOCAL nFirstTrayID := 0
LOCAL nOtherTrayID := 0
LOCAL nOldOrientation := 0
LOCAL cPathWord := cWin2Dos( DC_RegQuery(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe", "") )
#if XPPVER > 01890000
default lDruOrEdit to .f.
default lPrint to .f.
default nCopies to 1
default lVorschau to .f.
default nSchacht1 to 0
default nSchacht2 to 0
default nOrientation to 0 // Portrait = Normal
if !Fexists(cFile)
msgbox(mess1030+" "+cFile+" "+mess1029)
return .f.
endif
i := Rat( ".",cFile)
if i < 1
cFile := cFile + ".doc"
endif
IF(ValType(cSaveAs)=="C")
i := Rat( ".",cSaveAs)
if i < 1
cSaveAs := cSaveAs + ".doc"
endif
ENDIF
// Erzeugen einer ActiveX-Komponente
oWord := CreateObject("Word.Application")
IF Empty( oWord )
oWord := CreateObject("opendocument.WriterDocument.1")
ENDIF
IF Empty( oWord )
MsgBox( mess1 )
Return .f.
ENDIF
if lDruOrEdit
oWord := oWord:dynamicCast(ActiveXObject())
oWord:Quit := {||lWordFinished := .T.}
oWord:Visible := .T.
lWordFinished := .F.
else
#ifndef WAD
oWord:Visible := .F.
oWord:DisplayAlerts := .F.
#endif
endif
// Oeffnen eines Word-Dokuments und Zugriff auf
// eine Sammlung von Lesezeichen
oWord:documents:open( cFile )
oDoc := oWord:ActiveDocument
oBM := oDoc:Bookmarks
oDruckerSettings := oDoc:PageSetup
// Ersetzen des Lesezeichens durch einen neuen
// Wert
// Kundendaten
ReplaceBookmark(oBM , "M_KDNR" , m_kdnr ) // Kundenummer
// Speichern des Ergebnisses
IF(ValType(cSaveAs)=="C")
oDoc:saveas(cSaveAs)
ENDIF
// Sichern der aktuellen Einstellungen
nFirstTrayID := oDruckerSettings:FirstPageTray
nOtherTrayID := oDruckerSettings:OtherPagesTray
nOldOrientation := oDruckerSettings:Orientation
// Setzen der gew