| Name | Initial value | Comment |
|---|---|---|
| false | 0 | |
| oexcel | .NULL. | |
| true | -1 | |
| xlautomatic | -4105 | |
| xlcontinuous | 1 | |
| xldiagonaldown | 5 | |
| xldiagonalup | 6 | |
| xledgebottom | 9 | |
| xledgeleft | 7 | |
| xledgeright | 10 | |
| xledgetop | 8 | |
| xlinsidehorizontal | 12 | |
| xlinsidevertical | 11 | |
| xlmaximized | -1434 | Maximized Constant |
| xlmedium | -4138 | |
| xlminimized | -1440 | Minimize Constant |
| xlnone | -4142 | |
| xlthin | 2 | |
| xltop | -4160 |
LPARAMETERS tcwb, tcsheet
THIS.oexcel.workbooks(tcwb).worksheets(tcsheet).ACTIVATE()
IF (!ISNULL(THIS.oexcel))
THIS.oexcel.QUIT()
THIS.oexcel = .NULL.
ENDIF
LPARAMETERS tcwb
WITH THIS.oexcel
IF EMPTY(tcwb)
.activeworkbook.CLOSE()
ELSE
.workbooks(tcwb).CLOSE()
ENDIF
ENDWITH
* tcTargetWorkbook passed by reference !
LPARAMETERS tcsourcewb, tcsourcesheet, tctargetwb
WITH THIS.oexcel
IF (!EMPTY(tctargetwb))
* copy to existing Workbook
.sheets(tcsourcesheet).COPY(.workbooks(tctargetwb).sheets(1))
ELSE
* copy to a new Workbook
.sheets(tcsourcesheet).SELECT
.sheets(tcsourcesheet).COPY
tctargetwb = .activeworkbook.FULLNAME
ENDIF
ENDWITH
RETURN THIS.sheetname(tctargetwb)
LPARAMETERS tcrange
LOCAL lcretval
WITH THIS.oexcel
lcretval = .activesheet.RANGE(tcrange).VALUE
ENDWITH
RETURN lcretval
LPARAMETERS tcwb, tcsheet, tcrange, tcpwd, tllock
WITH THIS.oexcel
IF (EMPTY(tcwb))
tcwb = THIS.workbookname()
ENDIF
IF (EMPTY(tcsheet))
tcsheet = THIS.sheetname(tcwb)
ENDIF
.workbooks(tcwb).worksheets(tcsheet).RANGE(tcrange).locked = tllock
ENDWITH
LPARAMETERS tlforcenewinstance, tlvisible, tnwindowstate
LOCAL llretval, lcerror, llgetobjectfailed
WAIT WINDOW msg_openexcel NOWAIT
IF !tlforcenewinstance
llgetobjectfailed = .F.
lcerror = ON("error")
ON ERROR llgetobjectfailed=.T.
THIS.oexcel = GETOBJECT(, "Excel.Application")
ON ERROR &lcerror
ENDIF
IF llgetobjectfailed OR tlforcenewinstance
llgetobjectfailed = .F.
lcerror = ON("error")
ON ERROR llgetobjectfailed=.T.
THIS.oexcel = CREATEOBJECT("Excel.Application")
ON ERROR &lcerror
ENDIF
WAIT CLEAR
IF (TYPE("this.oExcel")="O" AND !ISNULL(THIS.oexcel))
IF (tlvisible)
THIS.oexcel.VISIBLE = .T.
ENDIF
llretval = .T.
ELSE
=MESSAGEBOX(msg_excelfailed,16,"Excel")
llretval = .F.
ENDIF
RETURN llretval
LPARAMETERS tcfilename, tlonlywhenclosed, tcwb
IF tlonlywhenclosed
IF TYPE("this.oExcel.Workbooks(tcWB)") = "O"
RETURN .T.
ENDIF
ENDIF
WITH THIS.oexcel
.workbooks.OPEN(tcfilename)
ENDWITH
LPARAMETERS tcwb, tcsheet, tcpwd
WITH THIS.oexcel
IF (EMPTY(tcwb))
tcwb = THIS.workbookname()
ENDIF
IF (EMPTY(tcsheet))
tcsheet = THIS.sheetname()
ENDIF
.workbooks(tcwb).worksheets(tcsheet).PROTECT(tcpwd, .T., .T., .T.)
ENDWITH
RELEASE THIS
LPARAMETERS tcwb, tcsheet, tcfilename, tcfileformat
IF (EMPTY(tcfileformat))
tcfileformat = "NORMAL"
ENDIF
tcfileformat = UPPER(tcfileformat)
WITH THIS.oexcel
.workbooks(tcwb).worksheets(tcsheet).ACTIVATE()
DO CASE
CASE tcfileformat == "EXCEL4WORKBOOK"
.workbooks(tcwb).SAVEAS(tcfilename, 35) && saves current workbook
CASE tcfileformat == "EXCEL4"
.workbooks(tcwb).SAVEAS(tcfilename, 33) && saves only the active Sheet
CASE tcfileformat == "EXCEL5"
.workbooks(tcwb).SAVEAS(tcfilename, 39) && saves all Sheets
CASE tcfileformat == "NORMAL"
.workbooks(tcwb).SAVEAS(tcfilename, -4143) && saves only the active Sheet
CASE tcfileformat == "TEXT"
.workbooks(tcwb).SAVEAS(tcfilename, 0) && saves only the active Sheet
CASE tcfileformat == "WK1"
.workbooks(tcwb).SAVEAS(tcfilename, 5) && saves only the active Sheet
CASE tcfileformat == "WK3"
.workbooks(tcwb).SAVEAS(tcfilename, 15) && saves only the active Sheet
CASE tcfileformat == "WK4"
.workbooks(tcwb).SAVEAS(tcfilename, 38) && saves only the active Sheet
CASE tcfileformat == "CSV"
.workbooks(tcwb).SAVEAS(tcfilename, 6) && saves only the active Sheet
ENDCASE
ENDWITH
LPARAMETERS tcrange, tcvalue, tllock
IF PARAMETERS() = 3
THIS.lockrange(tcrange, tllock)
ENDIF
THIS.oexcel.activesheet.RANGE(tcrange).VALUE = tcvalue
LPARAMETERS tcworkbookname
LOCAL lcsheetname
lcsheetname = ""
IF (EMPTY(tcworkbookname))
tcworkbookname = THIS.workbookname(.T.)
ENDIF
IF (!EMPTY(tcworkbookname))
lcsheetname = THIS.oexcel.workbooks(tcworkbookname).activesheet.NAME
ENDIF
RETURN lcsheetname
LPARAMETERS tcwb, tcsheet, tcpassword
THIS.oexcel.workbooks(tcwb).worksheets(tcsheet).unprotect(tcpassword)
LPARAMETERS tlshort
LOCAL lcworkbookname
lcworkbookname = ""
WITH THIS.oexcel
IF (.workbooks.COUNT > 0)
IF tlshort
lcworkbookname = .activeworkbook.NAME
ELSE
lcworkbookname = .activeworkbook.FULLNAME
ENDIF
ELSE
lcworkbookname = ""
ENDIF
ENDWITH
RETURN lcworkbookname
LPARAMETERS tnwindowstate
THIS.oexcel.WINDOWSTATE = tnwindowstate
LPARAMETERS tctemplate
LOCAL lcworkbookname
IF VARTYPE(THIS.oexcel)="O"
WITH THIS.oexcel
IF EMPTY(tctemplate)
.workbooks.ADD()
ELSE
.workbooks.ADD(tctemplate)
ENDIF
lcworkbookname = .activeworkbook.FULLNAME
ENDWITH
ENDIF
RETURN lcworkbookname
LPARAMETERS tcrange, tncolindex, tnpattern, tnpatterncolindex
WITH THIS.oexcel
.activesheet.RANGE(tcrange).interior.colorindex = tncolindex && = 44
.activesheet.RANGE(tcrange).interior.PATTERN = tnpattern && = 1
.activesheet.RANGE(tcrange).interior.patterncolorindex = tnpatterncolindex && -4105
ENDWITH
LPARAMETERS tccommand
WITH THIS.oexcel
&tccommand
ENDWITH
LPARAMETERS tcrange, tcformula
IF LEFT(tcformula,1) = "="
THIS.oexcel.activesheet.RANGE(tcrange).formula = tcformula
ENDIF
LPARAMETERS tcsourcerange, tctargetrange
LOCAL lccommand
lccommand = 'Set sourceRange = .ActiveSheet.Range("'+tcsourcerange+'") : ' +;
'set fillrange = .activesheet.range("'+tctargetrange+'") : ' +;
'sourcerange.autofill destination:=fillrange'
THIS.passthrough(lccommand)
LPARAMETERS tcref
LOCAL lnstart, lcrow
lcrow = ""
lnstart = 1
DO WHILE(lnstart <= LEN(tcref) AND !ISDIGIT(SUBSTR(tcref, lnstart)))
lnstart = lnstart + 1
ENDDO
IF (ISDIGIT(SUBSTR(tcref, lnstart)))
lcrow = SUBSTR(tcref, lnstart)
ENDIF
RETURN lcrow
LPARAMETERS tcrange, tnlinestyle, tnweight, tncolorindex, tlnotinside
WITH THIS.oexcel
.activesheet.RANGE(tcrange).SELECT
LOCAL lnline
FOR lnline = THIS.xledgeleft TO IIF(tlnotinside, THIS.xledgeright, THIS.xlinsidehorizontal)
.activesheet.RANGE(tcrange).BORDERS(lnline).linestyle = tnlinestyle
.activesheet.RANGE(tcrange).BORDERS(lnline).weight = tnweight
.activesheet.RANGE(tcrange).BORDERS(lnline).colorindex = tncolorindex
NEXT
ENDWITH
LPARAMETERS tcwb
THIS.oexcel.workbooks(tcwb).ACTIVATE()
LPARAMETERS tnformat
IF EMPTY(tnformat)
tnformat = -4154
ENDIF
THIS.oexcel.SELECTION.autoformat(tnformat)
LPARAMETERS tcrange, tctext
LOCAL locomment
WITH THIS.oexcel
.activesheet.RANGE(tcrange).addcomment(tctext)
.activesheet.RANGE(tcrange).COMMENT.VISIBLE = .T.
.activesheet.RANGE(tcrange).COMMENT.SHAPE.textframe.AUTOSIZE = .T.
ENDWITH
LPARAMETERS tcrange, tllock
THIS.oexcel.activesheet.RANGE(tcrange).locked = tllock
LPARAMETERS tcrange
THIS.oexcel.activesheet.RANGE(tcrange).clearcomments
LPARAMETERS tccolumn
* A->B, C->D, Z->AA, AZ->BA, BZ->CA ... IV
LOCAL lcretval, lnasc, lc1, lc2
IF LEN(tccolumn) = 1
lc1 = ""
ELSE
lc1 = LEFT(tccolumn, 1)
ENDIF
lc2 = CHR(ASC(RIGHT(tccolumn, 1)) +1)
IF lc2 > "Z"
lc2 = "A"
IF EMPTY(lc1)
lc1 = "A"
ELSE
lc1 = CHR(ASC(lc1) +1)
ENDIF
ENDIF
lcretval = lc1 + lc2
RETURN lcretval
LPARAMETERS tcrange, tlwraptext
THIS.oexcel.activesheet.COLUMNS(tcrange).wraptext = tlwraptext
LPARAMETERS tcrange, tnalignment
IF EMPTY(tnalignment)
tnalignment = THIS.xltop
ENDIF
THIS.oexcel.activesheet.COLUMNS(tcrange).verticalalignment = tnalignment
LPARAMETERS tcrange, tnwidth
THIS.oexcel.activesheet.COLUMNS(tcrange).COLUMNWIDTH = tnwidth
THIS.oexcel.activewindow.selectedsheets.printout(1)
LPARAMETERS tnrow
THIS.oexcel.activesheet.ROWS(tnrow).HIDDEN = .T.
LPARAMETERS tnrow
THIS.oexcel.activesheet.ROWS(tnrow).HIDDEN = .F.
LPARAMETERS tnrow
RETURN (THIS.oexcel.activesheet.ROWS(tnrow).HIDDEN)
| Name | Initial value | Comment |
|---|---|---|
| onamespace | .NULL. | |
| ooutlook | .NULL. | |
| outlfolderinbox | 6 | |
| outljournalitem | 4 | |
| outlmailitem | 0 | |
| outltaskitem | 3 |
LPARAMETERS llforcenewinstance
LOCAL llretval
llretval = .F.
WAIT WINDOW msg_openoutlook NOWAIT
LOCAL lcerror, llgetobjectfailed
lcerror = ON("ERROR")
ON ERROR llgetobjectfailed = .T.
THIS.lnewinstance=.F.
IF !llforcenewinstance
* An error occurs if outlook is currently not running.
llgetobjectfailed = .F.
THIS.ooutlook = GETOBJECT(,"Outlook.Application")
ENDIF
IF llgetobjectfailed OR llforcenewinstance
* An error occurs if outlook is not installed on this machine.
llgetobjectfailed = .F.
THIS.ooutlook = CREATEOBJECT("Outlook.Application")
ENDIF
ON ERROR &lcerror
WAIT CLEAR
IF (TYPE("this.oOutlook")="O" AND !ISNULL(THIS.ooutlook))
THIS.onamespace = THIS.ooutlook.getnamespace("MAPI")
llretval = .T.
ELSE
=MESSAGEBOX(msg_outlookfailed, 16, _SCREEN.CAPTION)
llretval = .F.
ENDIF
RETURN llretval
IF VARTYPE(this.oOutlook)="O"
WAIT WINDOW msg_closeoutlook NOWAIT
THIS.ooutlook.QUIT()
THIS.ooutlook=.NULL.
WAIT CLEAR
ENDIF
LPARAMETERS tcrecipient, tcsubject, tcbody, tcattachments, tlsavenotsent
LOCAL lomail, lorecipient, loattachments
* create new Mail Item
lomail=THIS.ooutlook.createitem(THIS.outlmailitem)
* add Recipient to the List of Recipients
lorecipient = lomail.recipients.ADD(ALLTRIM(tcrecipient))
* Check address.
IF lorecipient.resolve()
lomail.subject = ALLTRIM(tcsubject)
lomail.body = tcbody
* List of Attachments separated with |.
IF VARTYPE(tcAttachments)="C" AND !EMPTY(tcattachments)
lomail.body = lomail.body + CHR(13) + CHR(13)
loattachments = lomail.attachments
LOCAL lcattachment, lnattachment, lnattachmentcount
lnattachmentcount = getargcount(tcattachments, ";")
FOR lnattachment = 1 TO lnattachmentcount
lcattachment = getarg(tcattachments, lnattachment, ";")
loattachments.ADD(ALLTRIM(lcattachment))
NEXT
ENDIF
IF tlsavenotsent
lomail.SAVE()
ELSE
lomail.SEND()
ENDIF
ELSE
= MESSAGEBOX(msg_norecipient+": "+ALLTRIM(tcrecipient), 64, _SCREEN.CAPTION)
ENDIF
RETURN lomail
LPARAMETERS tcsearchexpr, tnindex
* open INBOX Folder
tnindex = 0
* Example for tcSearchExpr = ".Subject = '"+lcYourSubject+"'"
loitem = THIS.getnextmail(tcsearchexpr, @tnindex)
RETURN loitem
LPARAMETER tcsearchexpr, tnindex
* open INBOX Folder
LOCAL loinboxfolder
loinboxfolder = THIS.onamespace.getdefaultfolder(THIS.outlfolderinbox)
LOCAL loitem
loitem = .NULL.
IF VARTYPE(tcSearchExpr)="C" AND !EMPTY(tcsearchexpr)
LOCAL lnitem, lnitemcount
lnitemcount = loinboxfolder.items.COUNT
FOR lnitem = tnindex+1 TO lnitemcount
LOCAL lo
lo = loinboxfolder.items[lnItem]
WITH lo
IF (EVALUATE(tcsearchexpr))
loitem = lo
tnindex = lnitem
EXIT
ENDIF
ENDWITH
NEXT
ENDIF
RETURN loitem
RELEASE THIS
LPARAMETERS tcprofile, tcpassword, tlshowdialog, tlnewsession
IF VARTYPE(this.oNameSpace)="O"
THIS.onamespace.logon(tcprofile, tcpassword, tlshowdialog, tlnewsession)
ENDIF
IF VARTYPE(this.oNameSpace)="O"
THIS.onamespace.logoff()
ENDIF
RETURN THIS.ooutlook
LOCAL lotaskitem
* create new Task Item
lotaskitem = THIS.ooutlook.createitem(THIS.outltaskitem)
RETURN lotaskitem
LOCAL lotaskitem, lcerror, llfailed, lofolder
* create new Task Item
lotaskitem = THIS.ooutlook.createitem(THIS.outltaskitem)
lcerror = ON("error")
llfailed = .F.
ON ERROR llfailed = .T.
lotaskitem.assign
ON ERROR &lcerror
IF llfailed
lofolder = THIS.onamespace.getdefaultfolder(13)
lofolder.DISPLAY
lotaskitem = THIS.ooutlook.createitem(THIS.outltaskitem)
lotaskitem.assign
ENDIF
RETURN lotaskitem
RETURN THIS.onamespace.currentuser.NAME
LPARAMETERS tcfolderlocation
* tcFolderLocation = 'folder1;folder2;folder3'
LOCAL loretval
loretval = .NULL.
tcfolderlocation = UPPER(ALLTRIM(tcfolderlocation))
LOCAL loparent
loparent = THIS.getnamespace()
LOCAL lnargcount
lnargcount = getargcount(tcfolderlocation,";")
LOCAL lnarg, lcsearchfolder, llfound
llfound = .F.
lnarg = 1
DO WHILE lnarg <= lnargcount
llfound = .F.
lcsearchfolder = UPPER(getarg(tcfolderlocation, lnarg, ";"))
LOCAL lnnsfolder
lnnsfoldercount = loparent.folders.COUNT
FOR lnnsfolder = 1 TO lnnsfoldercount
IF (lcsearchfolder == UPPER(loparent.folders.ITEM(lnnsfolder).NAME))
lnarg = lnarg + 1
loparent = loparent.folders.ITEM(lnnsfolder)
llfound = .T.
EXIT
ENDIF
NEXT
IF !llfound
EXIT
ENDIF
ENDDO
IF llfound
loretval = loparent
ENDIF
RETURN loretval
RETURN THIS.onamespace
LOCAL lomailitem
* create new Mail Item
lomailitem = THIS.ooutlook.createitem(THIS.outlmailitem)
RETURN lomailitem
LOCAL lojournalitem
* create new Journal Item
lojournalitem = THIS.ooutlook.createitem(THIS.outljournalitem)
RETURN lojournalitem
| Name | Initial value | Comment |
|---|---|---|
| ^abookmarks[1,0] | .f. | Enthält alle Bookmarks eines Dokuments (wird mit der Methode ReadBookmarks gefüllt) |
| copendocuments | "" | String aller aus der Applikation heraus geöffneten Dokumente, mit ; getrennt |
| lopendocument_ok | .f. | Öffnen des Dokuments erfolgreich? |
| ncopies | 1 | Anzahl zu druckende Kopien |
| nsavechanges | 0 | Änderungen speichern? 0 - nicht speichern, -1 - speichern, -2 - Frage ob speichern |
| oword | .NULL. | Word Objekt |
LOCAL lncountmarks, lni
lncountmarks = THIS.oword.activedocument.bookmarks.COUNT
DIMENSION THIS.abookmarks[lnCountMarks]
FOR lni = 1 TO lncountmarks
THIS.abookmarks[lni] = THIS.oword.activedocument.bookmarks(lni).NAME
NEXT
LPARAMETERS lcdocumenttoopen
lcdocumenttoopen = ALLTRIM(lcdocumenttoopen)
LOCAL lcerror, llopenok
WAIT WINDOW lcdocumenttoopen + "..." NOWAIT
lcerror = ON("error")
llopenok = .T.
ON ERROR llopenok=.F.
THIS.oword.documents.OPEN(lcdocumenttoopen)
ON ERROR &lcerror
THIS.lopendocument_ok = llopenok
WAIT CLEAR
IF !THIS.lopendocument_ok
=MESSAGEBOX(msg_wordcannotopen+": " + lcdocumenttoopen, 64, _SCREEN.CAPTION)
ENDIF
LPARAMETERS llforcenewinstance
LOCAL lcerror, llgetobjectfailed
WAIT WINDOW msg_openword NOWAIT
IF !llforcenewinstance
lcerror = ON("error")
llgetobjectfailed = .F.
ON ERROR llgetobjectfailed=.T.
THIS.oword = GETOBJECT(, "Word.Application")
ON ERROR &lcerror
ENDIF
IF llgetobjectfailed OR llforcenewinstance
* Error handler inserted
lcerror = ON("error")
llgetobjectfailed = .F.
ON ERROR llgetobjectfailed=.T.
THIS.oword = CREATEOBJECT("Word.Application")
ON ERROR &lcerror
ENDIF
WAIT CLEAR
* Return .T. if Word is running
RETURN !llgetobjectfailed
LPARAMETERS lcdocumenttoclose
LOCAL lnparameters
lnparameters = PARAMETERS()
IF !THIS.checkword(.F.)
RETURN .F.
ENDIF
lcdocumenttoclose = IIF(lnparameters<1, THIS.oword.activedocument.NAME, ALLTRIM(lcdocumenttoclose))
IF TYPE("this.oWord.Documents(lcDocumenttoClose)") = "O"
IF THIS.nsavechanges = -2
LOCAL lcerror, llcloseok
llcloseok = .T.
lcerror = ON("error")
ON ERROR llcloseok=.F.
THIS.activateword()
THIS.oword.documents(lcdocumenttoclose).CLOSE(THIS.nsavechanges)
THIS.setwindowstate(2)
IF !llcloseok
THIS.oword.documents(lcdocumenttoclose).CLOSE(0)
ENDIF
ON ERROR &lcerror
ELSE
THIS.oword.documents(lcdocumenttoclose).CLOSE(THIS.nsavechanges)
ENDIF
ENDIF
LPARAMETERS lpn1
lpn1 = IIF(PARAMETERS()<1, 2, lpn1)
IF TYPE("this.oWord.Name") <> "U"
THIS.oword.WINDOWSTATE = lpn1
ENDIF
WITH THIS.oword
.VISIBLE = .T.
.WINDOWSTATE = 1
.ACTIVATE()
=MESSAGEBOX(msg_returntoapp, 64, _SCREEN.CAPTION)
THIS.setwindowstate()
ENDWITH
IF TYPE("this.oWord.Name") = "U"
RETURN .F.
ENDIF
THIS.oword.QUIT()
WAIT CLEAR
LPARAMETERS tcsaveas, tlpromptforsaveproperties, tnfileformat
IF PARAMETERS() < 1
tcsaveas = "X"+SUBSTR(SYS(2015),4,7)
ENDIF
WITH THIS.oword
LOCAL llsavepropertiesprompt
* save SavePropertiesPrompt
llsavepropertiesprompt = .options.savepropertiesprompt
* set SavePropertiesPrompt
.options.savepropertiesprompt = tlpromptforsaveproperties
IF EMPTY(tnfileformat)
.wordbasic.filesaveas(tcsaveas)
ELSE
.wordbasic.filesaveas(tcsaveas, tnfileformat)
ENDIF
* restore SavePropertiesPrompt
.options.savepropertiesprompt = llsavepropertiesprompt
ENDWITH
RETURN (tcsaveas)
LPARAMETERS lctext
THIS.oword.SELECTION.TEXT = lctext
LPARAMETERS lcbookmark
THIS.oword.SELECTION.GOTO(-1, , , lcbookmark)
LPARAMETERS tlupdatefieldsatprint
IF !THIS.checkword(.T.)
RETURN .F.
ENDIF
THIS.oword.VISIBLE = .T.
WAIT WINDOW THIS.oword.activedocument.NAME + " "+msg_wordprinting NOWAIT
WITH THIS.oword
LOCAL lloldupdatefieldsatprint
lloldupdatefieldsatprint = .options.updatefieldsatprint
.options.updatefieldsatprint = tlupdatefieldsatprint
.wordbasic.fileprint(1)
.options.updatefieldsatprint = lloldupdatefieldsatprint
ENDWITH
WAIT CLEAR
LOCAL lcerror
lcerror = ON("error")
ON ERROR x = .T.
THIS.oword.SELECTION.homekey(6)
ON ERROR &lcerror
THIS.oword.SELECTION.moveright(12)
lparameters lnsymbol, lcfont, llunicode
LPARAMETERS lcname, lctext
THIS.oword.activedocument.formfields(lcname).result = lctext
IF !THIS.checkword(.F.)
RETURN .F.
ENDIF
THIS.oword.documents.CLOSE(THIS.nsavechanges)
IF !THIS.checkword(.T.)
RETURN .F.
ENDIF
LOCAL lni
WITH THIS
FOR lni = 1 TO .oword.documents.COUNT
.activatedocument(.oword.DOCUMENT(lni).NAME)
.printdocument()
ENDFOR
.activatedocument(.oword.DOCUMENT(1).NAME)
ENDWITH
IF !THIS.checkword(.F.)
RETURN .F.
ENDIF
LOCAL lni, lcdocumenttoclose
WITH THIS
lni = 1
lcdocumenttoclose = getarg(.copendocuments, lni)
DO WHILE !EMPTY(lcdocumenttoclose)
.closedocument(lcdocumenttoclose)
lni = lni +1
lcdocumenttoclose = getarg(.copendocuments, lni)
ENDDO
ENDWITH
IF !THIS.checkword(.T.)
RETURN .F.
ENDIF
LOCAL lni, lcdocumenttoprint
WITH THIS
lni = 1
lcdocumenttoprint = getarg(.copendocuments, lni)
DO WHILE !EMPTY(lcdocumenttoprint)
IF .activatedocument(lcdocumenttoprint)
.printdocument()
ENDIF
lni = lni +1
lcdocumenttoprint = getarg(.copendocuments, lni)
ENDDO
.activatedocument(getarg(.copendocuments, 1))
ENDWITH
LPARAMETERS tlgetmessage
IF TYPE("this.oWord.Name") <> "U" AND THIS.oword.documents.COUNT > 0
RETURN .T.
ELSE
IF tlgetmessage
=MESSAGEBOX(msg_wordnotrunning, 64, _SCREEN.CAPTION)
ENDIF
RETURN .F.
ENDIF
LPARAMETERS lcdocumenttoopen
lcdocumenttoopen = ALLTRIM(lcdocumenttoopen)
LOCAL lcerror, llopenok
WAIT WINDOW lcdocumenttoopen + " "+msg_opendoc NOWAIT
lcerror = ON("error")
llopenok = .T.
ON ERROR llopenok=.F.
THIS.oword.documents.openasdocument(lcdocumenttoopen)
ON ERROR &lcerror
THIS.lopendocument_ok = llopenok
WAIT CLEAR
IF !THIS.lopendocument_ok
=MESSAGEBOX(msg_wordcannotopen+": " + lcdocumenttoopen, 64, _SCREEN.CAPTION)
ENDIF
LPARAMETERS lctemplate
lctemplate = IIF(PARAMETERS()<1,"",ALLTRIM(lctemplate))
LOCAL lcerror, llopenok
lcerror = ON("error")
llopenok = .T.
ON ERROR llopenok=.F.
THIS.oword.documents.ADD(lctemplate)
ON ERROR &lcerror
THIS.lopendocument_ok = llopenok
IF !THIS.lopendocument_ok
=MESSAGEBOX(msg_wordcannotopen+": " + lctemplate, 64, _SCREEN.CAPTION)
RETURN ""
ELSE
RETURN THIS.oword.activedocument.NAME
ENDIF
LPARAMETERS lcdocumenttoactivate
lcdocumenttoavtivate = ALLTRIM(lcdocumenttoactivate)
IF TYPE("this.oWord.Documents(lcDocumenttoActivate)") = "O"
THIS.oword.documents(lcdocumenttoactivate).ACTIVATE()
RETURN .T.
ELSE
=MESSAGEBOX(msg_wordcannotactivate+": " + TRIM(lcdocumenttoactivate), 64, _SCREEN.CAPTION)
RETURN .F.
ENDIF
LPARAMETERS lcautotext
THIS.oword.activedocument.attachedtemplate.autotextentries(lcautotext).INSERT(THIS.oword.SELECTION.RANGE, .T.)
LPARAMETERS tnunit, tncount
IF EMPTY(tnunit)
tnunit = 1
ENDIF
IF EMPTY(tncount)
tncount = 1
ENDIF
THIS.oword.SELECTION.DELETE(tnunit, tncount)
LPARAMETERS tcbookmark
WITH THIS.oword
.SELECTION.GOTO(-1, , , tcbookmark)
.SELECTION.FIELDS.UPDATE
ENDWITH
LPARAMETERS tlvisible
tlvisible = IIF(PARAMETERS()<1, .T., tlvisible)
THIS.oword.VISIBLE = tlvisible
LPARAMETERS tnmaindacumenttype, tcfilename, tlsuppress
tlsuppress = IIF(PARAMETERS()<3,.T.,tlsuppress)
WITH THIS.oword
.activedocument.mailmerge.maindocumenttype = tnmaindacumenttype
IF tnmaindacumenttype <> -1
.wordbasic.mailmergeopendatasource(tcfilename, 0, 0, 1, 0, "", "", 0, "", "", "Entire Spreadsheet", "", "")
.wordbasic.mailmerge(1, 0, 0, "", "", 0)
ENDIF
.activedocument.mailmerge.suppressblanklines = tlsuppress
ENDWITH
LOCAL lcerror
lcerror = ON("error")
ON ERROR x = .T.
THIS.oword.SELECTION.endkey(6)
ON ERROR &lcerror
LPARAMETERS tlview
THIS.oword.activedocument.mailmerge.viewmailmergefieldcodes = tlview
LPARAMETERS tlsuppress
tlsuppress = IIF(PARAMETERS()<1, .T., tlsuppress)
THIS.oword.activedocument.mailmerge.suppressblanklines = tlsuppress
LPARAMETERS tcdocumenttocheck, tlgetmessage
IF TYPE("this.oWord.Documents(tcDocumenttoCheck)") = "O"
RETURN .T.
ELSE
IF tlgetmessage
=MESSAGEBOX(msg_worddocnotopen+": " + TRIM(tcdocumenttocheck), 64, _SCREEN.CAPTION)
ENDIF
RETURN .F.
ENDIF
IF !THIS.checkword(.T.)
RETURN .F.
ENDIF
WAIT WINDOW THIS.oword.activedocument.NAME + " "+msg_wordprinting NOWAIT
WITH THIS.oword.activedocument.mailmerge
LOCAL lcerror, llcloseok
llcloseok = .T.
lcerror = ON("error")
ON ERROR llcloseok=.F.
.destination = 1
.execute()
ON ERROR &lcerror
ENDWITH
LPARAMETERS tcbookmark
IF EMPTY(tnunit)
tnunit = 1
ENDIF
IF EMPTY(tncount)
tncount = 1
ENDIF
THIS.oword.activedocument.bookmarks(tcbookmark).DELETE
LPARAMETERS tcbookmark
THIS.oword.activedocument.bookmarks(tcbookmark).SELECT
THIS.oword.SELECTION.homekey(5)
THIS.oword.SELECTION.endkey(5, 1)
THIS.oword.SELECTION.DELETE(1, 1)
WITH THIS.oword
.VISIBLE = .T.
.WINDOWSTATE = 1
.ACTIVATE()
ENDWITH
IF !THIS.checkword(.T.)
RETURN .F.
ENDIF
WITH THIS.oword
.SELECTION.wholestory
.SELECTION.FIELDS.UPDATE
ENDWITH
IF !THIS.checkword(.T.)
RETURN .F.
ENDIF
LOCAL lcerror
lcerror = ON("error")
ON ERROR x = .T.
THIS.oword.SELECTION.paste()
ON ERROR &lcerror
LPARAMETERS tcdocument, tnfirstpagetray, tnotherpagetray
IF !THIS.checkword(.F.)
RETURN .F.
ENDIF
IF EMPTY(tcdocument)
tcdocument = THIS.oword.activedocument.NAME
ENDIF
IF EMPTY(tnfirstpagetray)
tnfirstpagetray = 0
ENDIF
IF EMPTY(tnotherpagetray)
tnotherpagetray = 0
ENDIF
IF TYPE("this.oWord.Documents(tcDocument)") = "O"
WITH THIS.oword.documents(tcdocument).pagesetup
.firstpagetray = tnfirstpagetray
.otherpagestray = tnotherpagetray
ENDWITH
ENDIF
THIS.oword.SELECTION.cells.DELETE(2)
LPARAMETERS tcfootnote, tctext, tlnoseparator, tcreferencefont, tnreferencesize, tctextfont, tntextsize
WITH THIS.oword
.activedocument.footnotes.ADD(.SELECTION.RANGE, tcfootnote, tctext)
IF tlnoseparator
.activedocument.footnotes.SEPARATOR.DELETE
ENDIF
IF !EMPTY(tcreferencefont)
.activedocument.footnotes(.activedocument.footnotes.COUNT).REFERENCE.FONT.NAME = tcreferencename
ENDIF
IF !EMPTY(tnreferencesize)
.activedocument.footnotes(.activedocument.footnotes.COUNT).REFERENCE.FONT.SIZE = tnreferencesize
ENDIF
IF !EMPTY(tctextfont)
.activedocument.footnotes(.activedocument.footnotes.COUNT).RANGE.FONT.NAME = tctextfont
ENDIF
IF !EMPTY(tntextsize)
.activedocument.footnotes(.activedocument.footnotes.COUNT).RANGE.FONT.SIZE = tntextsize
ENDIF
ENDWITH
LPARAMETERS tnsection
RETURN (THIS.oword.activedocument.sections(tnsection).RANGE.footnotes.COUNT)
LPARAMETERS tnreferencetype, tnreferencekind, tcreferenceitem, tlinsertashyperlink, tlincludeposition
WITH THIS.oword
.SELECTION.insertcrossreference(tnreferencetype, tnreferencekind, tcreferenceitem, ;
tlinsertashyperlink, tlincludeposition)
ENDWITH
LPARAMETERS tlforcesave
IF !THIS.checkword(.F.)
RETURN .F.
ENDIF
LOCAL llret
WITH THIS.oword
IF THIS.checkdocument(.activedocument)
*-- sicherstellen, dass auch wirklich gespeichert wird
IF tlforcesave
.SELECTION.typetext(" ")
.SELECTION.typebackspace
ENDIF
.activedocument.SAVE()
llret = .T.
ELSE
llret = .F.
ENDIF
ENDWITH
RETURN (llret)