WordAutomation/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: WordAutomation/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Zurück zur [[Office Automation/de|Office Automation]].\ | |
| 2 | + | ||
| 3 | + | =Word als OleObjekt= Word lässt sich wie alle MS Office Produkte automatisieren. Im Gegensatz zu den übrigen MS Office Produkten ist es bei der Automatisierung sehr sehr langsam und reagiert sehr ungewohnt.\ | |
| 4 | + | Wenn man als Automatisierungsobjekt nicht zwingend auf MS Word angewiesen ist, dann sollte man für die Automatisierung MS Excel nehmen.\ | |
| 5 | + | Wenn Sie Umlaute usw. verwenden, dann sollten Sie wissen, dass Word UTF16 codierte Strings verwendet.\ | |
| 6 | + | Für die Oleautomation muss die Unit **ComObj** eingebunden werden.\ | |
| 7 | + | Wenn Sie mit Umlauten usw. arbeiten dann brauchen Sie für das Stringcasting die Unit **lclproc**.\ | |
| 8 | + | ||
| 9 | + | Beispiel:\ | |
| 10 | + | ||
| 11 | + | ``` pascal | |
| 12 | + | unit | |
| 13 | + | ComObj, lclproc; | |
| 14 | + | ``` | |
| 15 | + | ||
| 16 | + | =Speicherplatz für Word und Worddokument reservieren= | |
| 17 | + | ||
| 18 | + | ``` pascal | |
| 19 | + | var | |
| 20 | + | varWdApp: oleVariant; // Reserviert Speicher für die Programmsteuerung | |
| 21 | + | varDokument: oleVariant; // Reserviert Speicher für die Steuerung des Worddokuments | |
| 22 | + | ``` | |
| 23 | + | ||
| 24 | + | =Wordsteuerung= | |
| 25 | + | ||
| 26 | + | ## Word OleObjekt erstellen | |
| 27 | + | ||
| 28 | + | ``` pascal | |
| 29 | + | begin | |
| 30 | + | ... | |
| 31 | + | try | |
| 32 | + | varWdApp := CreateOleObject('Word.Application'); // erstellt das Wordobjekt | |
| 33 | + | except | |
| 34 | + | WriteLn('MS Word kann nicht gestartet werden.'); // Fehlerbehandlung | |
| 35 | + | end; | |
| 36 | + | ... | |
| 37 | + | end; | |
| 38 | + | ``` | |
| 39 | + | ||
| 40 | + | ==Word Version ermitteln== | |
| 41 | + | ||
| 42 | + | ``` pascal | |
| 43 | + | begin | |
| 44 | + | ... | |
| 45 | + | ShowMessage(varWdApp.Version); | |
| 46 | + | ... | |
| 47 | + | end; | |
| 48 | + | ``` | |
| 49 | + | ||
| 50 | + | ==Word beenden und Speicher freigeben== | |
| 51 | + | ||
| 52 | + | ``` pascal | |
| 53 | + | begin | |
| 54 | + | ... | |
| 55 | + | varWdApp.Quit; | |
| 56 | + | varWdApp := Unassigned; | |
| 57 | + | ... | |
| 58 | + | end; | |
| 59 | + | ``` | |
| 60 | + | ||
| 61 | + | ==Die Sichtbarkeit von Word steuern== Eine unsichtbare Anwendung verhindert während der Automatisierung das Flackern des Bildschirms.\ | |
| 62 | + | ||
| 63 | + | ``` pascal | |
| 64 | + | begin | |
| 65 | + | ... | |
| 66 | + | varWdApp.Visible := False; // macht Word unsichtbar | |
| 67 | + | varWdApp.Visible := True; // macht Word sichtbar | |
| 68 | + | ... | |
| 69 | + | end; | |
| 70 | + | ``` | |
| 71 | + | ||
| 72 | + | ==Word Screenupdating (Bildschirmaktualisierung)== | |
| 73 | + | ||
| 74 | + | ``` pascal | |
| 75 | + | begin | |
| 76 | + | ... | |
| 77 | + | varWdApp.ScreenUpdating := False; // schaltet bei einem sichtbaren Word das Flackern des Bildschirms aus | |
| 78 | + | // und erhöht die Verarbeitungsgeschwindigkeit. | |
| 79 | + | varWdApp.ScreenUpdating := True; // schaltet die Bildschirmaktualisierung wieder ein. | |
| 80 | + | ... | |
| 81 | + | end; | |
| 82 | + | ``` | |
| 83 | + | ||
| 84 | + | ==Sprache der Wordinstallation ermittlen== | |
| 85 | + | ||
| 86 | + | ``` pascal | |
| 87 | + | begin | |
| 88 | + | ... | |
| 89 | + | if varWdApp.System.Country <> wdGermany then ... // prüft, ob die Wordinstallation nicht Deutsch ist. | |
| 90 | + | ... | |
| 91 | + | end; | |
| 92 | + | ``` | |
| 93 | + | ||
| 94 | + | =Text des Dokuments bearbeiten= | |
| 95 | + | ||
| 96 | + | ## Neues Worddokument erstellen | |
| 97 | + | ||
| 98 | + | ``` pascal | |
| 99 | + | begin | |
| 100 | + | ... | |
| 101 | + | varDokument := varWdApp.Documents.Add; // fügt ein neues 'leeres' Worddokument hinzu | |
| 102 | + | ... | |
| 103 | + | end; | |
| 104 | + | ``` | |
| 105 | + | ||
| 106 | + | ==Vorhandenes Worddokument öffnen== Es gibt mehrere Möglichkeiten ein Worddokument zu öffnen.\ | |
| 107 | + | ||
| 108 | + | Beispiel 1:\ | |
| 109 | + | Ein Worddokument mit mehreren Parametern öffnen\ | |
| 110 | + | Alle Parameter außer Parameter 1 sind optional\ | |
| 111 | + | \# Parameter: Pfadname und Datename\ | |
| 112 | + | \#Parameter: False, wenn die Datei nicht in das aktuelle Wordformat konvertiert werden soll\ | |
| 113 | + | \#Parameter: True, wenn die Datei schreibgeschützt geöffnet werden soll\ | |
| 114 | + | \#Parameter: True, wenn der Name der Datei der Liste der zuletzt geöffneten Dateien hizugefügt werden soll\ | |
| 115 | + | \#Parameter: Das Kennwort (Passwort) zum öffnen der Vorlage\ | |
| 116 | + | \#Parameter:\ | |
| 117 | + | \#Parameter: Das Kennwort (Passwort) zum Speichern des Dokuments\ | |
| 118 | + | \#Parameter: Das Kennwort (Passwort) zum Speichern der Vorlage\ | |
| 119 | + | \#Parameter:\ | |
| 120 | + | \#Parameter: Das Dateikonvertierungsprogramm, das zum Öffnen des Dokuments verwendet werden soll. Der Standardwert ist wdOpenFormatAuto | |
| 121 | + | ||
| 122 | + | ``` pascal | |
| 123 | + | begin | |
| 124 | + | ... | |
| 125 | + | varDokument := varWdApp.Documents.Open(FileName, EmptyParam, EmptyParam, | |
| 126 | + | EmptyParam, EmptyParam, EmptyParam, | |
| 127 | + | EmptyParam, EmptyParam, EmptyParam, | |
| 128 | + | EmptyParam); | |
| 129 | + | ... | |
| 130 | + | end; | |
| 131 | + | ``` | |
| 132 | + | ||
| 133 | + | Beispiel 2:\ | |
| 134 | + | Ein Worddokument mit einem Umlaut usw. im Dateinamen öffnen\ | |
| 135 | + | ||
| 136 | + | ``` pascal | |
| 137 | + | begin | |
| 138 | + | ... | |
| 139 | + | varDokument := varWdApp.Documents.Open(UTF8ToUTF16('D:\Üben.doc')); // Öffnet ein Worddokument mit Umlauten usw. im Namen | |
| 140 | + | ... | |
| 141 | + | end; | |
| 142 | + | ``` | |
| 143 | + | ||
| 144 | + | Beispiel 3:\ | |
| 145 | + | ||
| 146 | + | ``` pascal | |
| 147 | + | begin | |
| 148 | + | ... | |
| 149 | + | varDokument := varWdApp.Documents.Open(strPfad); // öffnet ein Worddokument mit Hilfe einer Variablen | |
| 150 | + | // (Pfad: maximal 255 Zeichen, Alphanumerisch) | |
| 151 | + | varDokument := varWdApp.Documents.Open('D:\Test.doc'); // öffnet ein Worddokument mit festem Pfad hinzu | |
| 152 | + | ... | |
| 153 | + | end; | |
| 154 | + | ``` | |
| 155 | + | ||
| 156 | + | ## Worddokument aktivieren | |
| 157 | + | ||
| 158 | + | ``` pascal | |
| 159 | + | begin | |
| 160 | + | ... | |
| 161 | + | varDokument.Activate; //aktiviert das Worddokument | |
| 162 | + | ... | |
| 163 | + | end; | |
| 164 | + | ``` | |
| 165 | + | ||
| 166 | + | ==Text Cursor setzen== | |
| 167 | + | ||
| 168 | + | ``` pascal | |
| 169 | + | begin | |
| 170 | + | ... | |
| 171 | + | varWdApp.Selection.EndKey(wdStory); // Cursor bewegt sich zum Ende des Dokumentes | |
| 172 | + | varWdApp.Selection.HomeKey(wdStory); // Cursor bewegt sich zum Anfang des Dokumentes | |
| 173 | + | varWdApp.Selection.MoveRight(wdWord); // Cursor am Anfang des nächsten Wortes | |
| 174 | + | varWdApp.Selection.MoveLeft(wdCharacter); // Cursor wird um ein Zeichen nach Links versetzt | |
| 175 | + | varWdApp.Selection.Delete(wdCharacter); // Löscht ein Zeichen rechts vom Cursor | |
| 176 | + | varWdApp.Selection.MoveDown(wdParagraph); // Cursor bewegt sich zum Anfang des nächsten Abschnitts | |
| 177 | + | ... | |
| 178 | + | end; | |
| 179 | + | ``` | |
| 180 | + | ||
| 181 | + | ==Text in ein Worddokument einfügen== | |
| 182 | + | ||
| 183 | + | ``` pascal | |
| 184 | + | begin | |
| 185 | + | ... | |
| 186 | + | varWdApp.Selection.TypeText(UTF8Decode('Neuer Text')); | |
| 187 | + | varWdApp.Selection.TypeText(UTF8Decode('Zusätzlicher Text')); // Benötigt die Unit lclproc für die korrekte | |
| 188 | + | // Umwandlung der Umlaute | |
| 189 | + | ||
| 190 | + | varWdApp.Selection.InsertAfter('Test'); // fügt im Worddokument nach der Cursorposition diesen Text ein | |
| 191 | + | // die Cursorpsition befindet sich bei einem frisch geöffneten Worddokument | |
| 192 | + | // immer am Anfang des Dokuments | |
| 193 | + | ||
| 194 | + | ... | |
| 195 | + | end; | |
| 196 | + | ``` | |
| 197 | + | ||
| 198 | + | ## Worddokument speichern | |
| 199 | + | ||
| 200 | + | Beispiel 1:\ | |
| 201 | + | Ein Worddokument ohne Besonderheiten im Namen speichern.\ | |
| 202 | + | ||
| 203 | + | ``` pascal | |
| 204 | + | begin | |
| 205 | + | ... | |
| 206 | + | varDokument.SaveAs('D:\Test.doc'); // Speichert das Worddokument unter einem neuen Namen | |
| 207 | + | varDokument.Save; // Speichert das Worddokument unter seinem aktuellen Namen | |
| 208 | + | ... | |
| 209 | + | end; | |
| 210 | + | ``` | |
| 211 | + | ||
| 212 | + | Beispiel 2:\ | |
| 213 | + | Ein Worddokment mit Umlaut im Namen speichern.\ | |
| 214 | + | ||
| 215 | + | ``` pascal | |
| 216 | + | begin | |
| 217 | + | ... | |
| 218 | + | varDokument.SaveAs(UTF8ToUTF16('D:\Üben.doc')); // Speichert das Worddokument (mit Umlauten usw. im Namen) | |
| 219 | + | // unter einem neuen Namen ab | |
| 220 | + | ... | |
| 221 | + | end; | |
| 222 | + | ``` | |
| 223 | + | ||
| 224 | + | Beispiel 3:\ | |
| 225 | + | Ein Worddokument in einem anderen Datei-Format speichern. | |
| 226 | + | ||
| 227 | + | ``` pascal | |
| 228 | + | const | |
| 229 | + | // Möglichkeiten wären u.a. | |
| 230 | + | // https://docs.microsoft.com/de-de/office/vba/api/word.wdsaveformat | |
| 231 | + | wdFormatDocument97 = 0; // .doc format | |
| 232 | + | wdFormatRTF = 6; | |
| 233 | + | wdFormatHTML = 8; | |
| 234 | + | wdFormatXML = 11; | |
| 235 | + | wdFormatDocumentDefault = 16; // .docx format | |
| 236 | + | wdFormatPDF = 17; | |
| 237 | + | wdFormatOpenDocumentText = 23; | |
| 238 | + | var | |
| 239 | + | FileFormat: OleVariant; // Wichtig: das muss als OleVariant deklariert sein! | |
| 240 | + | begin | |
| 241 | + | FileFormat := wdFormatRTF; | |
| 242 | + | ADocument.SaveAs(FileName, FileFormat); | |
| 243 | + | ... | |
| 244 | + | ``` | |
| 245 | + | ||
| 246 | + | ## Worddokument schliessen und Speicher freigeben | |
| 247 | + | ||
| 248 | + | ``` pascal | |
| 249 | + | begin | |
| 250 | + | ... | |
| 251 | + | varDokument.Close; // Schliesst das Worddokument | |
| 252 | + | varDokument := Unassigned; // Gibt den Speicher für die Programmsteuerung frei | |
| 253 | + | ... | |
| 254 | + | end; | |
| 255 | + | ``` | |
| 256 | + | ||
| 257 | + | ==Worddokument Eigenschaften festlegen== Alle Eigenschaften des Worddokumentes können über ihren englischen Namen angesprochen werden.\ | |
| 258 | + | ||
| 259 | + | ``` pascal | |
| 260 | + | begin | |
| 261 | + | ... | |
| 262 | + | varDokument.BuiltInDocumentProperties['Title'].Value := 'Testdokument'; // fügt den Dokumententitel ein | |
| 263 | + | varDokument.BuiltInDocumentProperties['Subject'].Value := 'Testdokumente'; // fügt das Thema ein | |
| 264 | + | varDokument.BuiltInDocumentProperties['Author'].Value := 'Testuser'; // fügt den Ersteller ein | |
| 265 | + | varDokument.BuiltInDocumentProperties['Manager'].Value := 'Testmanager'; // fügt den verantwortlichen Manager ein | |
| 266 | + | varDokument.BuiltInDocumentProperties['Company'].Value := 'Testfirma'; // fügt die Firma ein | |
| 267 | + | varDokument.BuiltInDocumentProperties['Category'].Value := 'Automatisationsbeispiele'; // fügt die Kategorie ein | |
| 268 | + | varDokument.BuiltInDocumentProperties['Comments'].Value := 'Erstes Muster'; // fügt einen Kommentar ein | |
| 269 | + | ... | |
| 270 | + | end; | |
| 271 | + | ``` | |
| 272 | + | ||
| 273 | + | ==Absatz==\ | |
| 274 | + | ===Absatz ausrichten=== | |
| 275 | + | ||
| 276 | + | ``` pascal | |
| 277 | + | begin | |
| 278 | + | ... | |
| 279 | + | varWdApp.Selection.ParagraphFormat.Alignment := wdAlignParagraphright; // Ausrichtung am rechten Dokumentrand | |
| 280 | + | varWdApp.Selection.ParagraphFormat.Alignment := wdAlignParagraphLeft; // Ausrichtung am linken Dokumentrand | |
| 281 | + | varWdApp.Selection.ParagraphFormat.Alignment := wdAlignParagraphCenter; // Ausrichtung in der Dokumentmitte | |
| 282 | + | ... | |
| 283 | + | end; | |
| 284 | + | ``` | |
| 285 | + | ||
| 286 | + | ===Absatz (Zeilenumbruch) einfügen=== | |
| 287 | + | ||
| 288 | + | ``` pascal | |
| 289 | + | begin | |
| 290 | + | ... | |
| 291 | + | varWdApp.Selection.TypeParagraph; // fügt einen Zeilenumbruch (Absatz) ein | |
| 292 | + | // Alternative | |
| 293 | + | varWdApp.Selection.InsertAfter(String(#13)); // fügt einen Zeilenumbruch im Worddokument ein | |
| 294 | + | varWdApp.Selection.InsertAfter(String(#10)); // fügt einen Zeilenumbruch im Worddokument ein | |
| 295 | + | ... | |
| 296 | + | end; | |
| 297 | + | ``` | |
| 298 | + | ||
| 299 | + | ==Text formatieren== Der Text wird an der Cursorposition formatiert. | |
| 300 | + | ||
| 301 | + | ``` pascal | |
| 302 | + | begin | |
| 303 | + | ... | |
| 304 | + | varWdApp.Selection.Font.Name := 'Times New Roman'; // Schriftart | |
| 305 | + | varWdApp.Selection.Font.Size := 12; // Schriftgrösse | |
| 306 | + | varWdApp.Selection.Font.Bold := True; // Fettschrift | |
| 307 | + | varWdApp.Selection.Font.Italic := True; // Kursivschrift | |
| 308 | + | ||
| 309 | + | varWdApp.Selection.Font.Name := 'Arial'; // Schriftart | |
| 310 | + | varWdApp.Selection.Font.Size := 11; // Schriftgrösse | |
| 311 | + | varWdApp.Selection.Font.Bold := False; // keine Fettschrift | |
| 312 | + | varWdApp.Selection.Font.Italic := False; // keine Kursivschrift | |
| 313 | + | ... | |
| 314 | + | end; | |
| 315 | + | ``` | |
| 316 | + | ||
| 317 | + | ==Bookmarks==\ | |
| 318 | + | ===Speicher für die Bookmarksteuerung reservieren=== | |
| 319 | + | ||
| 320 | + | ``` pascal | |
| 321 | + | var | |
| 322 | + | varBookmark: oleVariant; // Reserviert Speicher für die Steuerung der Bookmark | |
| 323 | + | ``` | |
| 324 | + | ||
| 325 | + | ===Variable initialisieren=== | |
| 326 | + | ||
| 327 | + | ``` pascal | |
| 328 | + | begin | |
| 329 | + | ... | |
| 330 | + | // Fügt an der Stelle einer Bookmark (Textmarke / Markierung) einen Text ein | |
| 331 | + | varBookmark := varDokument.Bookmarks.Item(2); // Auswahl der zu ersetzenden Bookmark (Markierung) über den Index | |
| 332 | + | // in diesem Fall ist es die erste Bookmark | |
| 333 | + | // Alternative | |
| 334 | + | varBookmark := varDokument.Bookmarks.Item('Test2'); // Auswahl der zu ersetzenden Bookmark (Markierung) über ihren Namen | |
| 335 | + | ... | |
| 336 | + | end; | |
| 337 | + | ``` | |
| 338 | + | ||
| 339 | + | ===An die Anfangsposition der Bookmark schreiben=== | |
| 340 | + | ||
| 341 | + | ``` pascal | |
| 342 | + | begin | |
| 343 | + | ... | |
| 344 | + | varBookmark.Range.Text := UTF8ToUTF16('Testeintrag für die Bookmark'); // damit wird an der Position der | |
| 345 | + | // Bookmark der Text eingefügt. | |
| 346 | + | ... | |
| 347 | + | end; | |
| 348 | + | ``` | |
| 349 | + | ||
| 350 | + | ===Bookmark löschen=== | |
| 351 | + | ||
| 352 | + | ``` pascal | |
| 353 | + | begin | |
| 354 | + | ... | |
| 355 | + | // Löscht, die ausgewählte Bookmark und nicht den eingefügten Text | |
| 356 | + | varDokument.Bookmarks.Item(1).Delete; // Löscht die Bookmark über einen Index | |
| 357 | + | // Alternative | |
| 358 | + | varDokument.Bookmarks.Item('Test1').Delete; // Löscht die Bookmark über ihren Namen | |
| 359 | + | ... | |
| 360 | + | end; | |
| 361 | + | ``` | |
| 362 | + | ||
| 363 | + | ===Variable für Bookmarksteuerung freigeben=== | |
| 364 | + | ||
| 365 | + | ``` pascal | |
| 366 | + | begin | |
| 367 | + | ... | |
| 368 | + | varBookmark := Unassigned; | |
| 369 | + | ... | |
| 370 | + | end; | |
| 371 | + | ``` | |
| 372 | + | ||
| 373 | + | ===Prüfen, ob eine bestimmte Bookmark vorhanden ist=== | |
| 374 | + | ||
| 375 | + | ``` pascal | |
| 376 | + | begin | |
| 377 | + | ... | |
| 378 | + | if varDokument.Bookmarks.Exists('Text1') then ... ; //Prüft, ob eine Bookmark vorhanden ist | |
| 379 | + | ... | |
| 380 | + | end; | |
| 381 | + | ``` | |
| 382 | + | ||
| 383 | + | ===Bookmarks zählen=== | |
| 384 | + | ||
| 385 | + | ``` pascal | |
| 386 | + | var | |
| 387 | + | intAnz: Integer; | |
| 388 | + | begin | |
| 389 | + | ... | |
| 390 | + | intAnz := varDokument.Bookmarks.Count; | |
| 391 | + | ... | |
| 392 | + | end; | |
| 393 | + | ``` | |
| 394 | + | ||
| 395 | + | ==Formularfelder==\ | |
| 396 | + | ===In ein Formularfeld schreiben=== | |
| 397 | + | ||
| 398 | + | ``` pascal | |
| 399 | + | begin | |
| 400 | + | ... | |
| 401 | + | varWdApp.ActiveDocument.FormFields.Item('Text1').Result := 'Versuch'; // schreibt in ein Formularfeld | |
| 402 | + | varWdApp.ActiveDocument.FormFields.Item('Text1').Result := ''; // leert ein Formularfeld | |
| 403 | + | ... | |
| 404 | + | ``` | |
| 405 | + | ||
| 406 | + | ===Ein Formularfeld auslesen=== | |
| 407 | + | ||
| 408 | + | ``` pascal | |
| 409 | + | var | |
| 410 | + | strText: String; | |
| 411 | + | begin | |
| 412 | + | ... | |
| 413 | + | strText := varWdApp.ActiveDocument.FormFields.Item('Text2').Result; // liest ein Formularfeld aus | |
| 414 | + | ... | |
| 415 | + | end; | |
| 416 | + | ``` | |
| 417 | + | ||
| 418 | + | ## Tabellen | |
| 419 | + | ||
| 420 | + | ===Speicher für die Tabellensteuerung reservieren=== | |
| 421 | + | ||
| 422 | + | ``` pascal | |
| 423 | + | var | |
| 424 | + | varTabelle: oleVariant; | |
| 425 | + | ``` | |
| 426 | + | ||
| 427 | + | ===Arbeiten mit neuen Tabellen===\ | |
| 428 | + | ====Variable initialisieren und Tabelle anlegen==== | |
| 429 | + | ||
| 430 | + | ``` pascal | |
| 431 | + | begin | |
| 432 | + | ... | |
| 433 | + | varTabelle := varDokument.Tables.Add(varWdApp.Selection.Range, 5, 3); | |
| 434 | + | ... | |
| 435 | + | end; | |
| 436 | + | ``` | |
| 437 | + | ||
| 438 | + | ====Die neu angelegte Tabelle füllen==== | |
| 439 | + | ||
| 440 | + | ``` pascal | |
| 441 | + | begin | |
| 442 | + | ... | |
| 443 | + | varTabelle.Cell(1, 1).Range.Text := 'Januar'; | |
| 444 | + | varTabelle.Cell(1, 2).Range.Text := 'Februar'; | |
| 445 | + | varTabelle.Cell(1, 3).Range.Text := UTF8ToUTF16('März'); | |
| 446 | + | ... | |
| 447 | + | end; | |
| 448 | + | ``` | |
| 449 | + | ||
| 450 | + | ===Arbeiten mit vorhandenen Tabellen=== | |
| 451 | + | ||
| 452 | + | ``` pascal | |
| 453 | + | var | |
| 454 | + | intAnz: Integer; | |
| 455 | + | begin | |
| 456 | + | ... | |
| 457 | + | varDokument.Tables.Item(1).Cell(2, 2).Range.Text:='Hallo'; // fügt in einen Wert in eine Zelle ein | |
| 458 | + | varDokument.Tables.Item(1).Rows.Add(); // fügt am Ende der Tabelle eine Zeile an | |
| 459 | + | intAnz:=varDokument.Tables.Item(1).Rows.Count; // ermittelt die Anzahl der Zeilen | |
| 460 | + | ... | |
| 461 | + | end; | |
| 462 | + | ``` | |
| 463 | + | ||
| 464 | + | ===Tabellenvariable wieder freigeben=== | |
| 465 | + | ||
| 466 | + | ``` pascal | |
| 467 | + | begin | |
| 468 | + | ... | |
| 469 | + | varTabelle := Unassigned; | |
| 470 | + | ... | |
| 471 | + | end; | |
| 472 | + | ``` | |
| 473 | + | ||
| 474 | + | =Auszug aus den Wordkonstanten= | |
| 475 | + | ||
| 476 | + | ``` pascal | |
| 477 | + | unit uWdConst; | |
| 478 | + | ||
| 479 | + | interface | |
| 480 | + | ||
| 481 | + | const | |
| 482 | + | // Klasse WdGoToItem | |
| 483 | + | wdGoToBookmark = -1; | |
| 484 | + | wdGoToComment = 6; | |
| 485 | + | wdGoToEndnote = 5; | |
| 486 | + | wdGoToEquation = 10; | |
| 487 | + | wdGoToField = 7; | |
| 488 | + | wdGoToFootnote = 4; | |
| 489 | + | wdGoToGrammaticalError = 14; | |
| 490 | + | wdGoToGraphic = 8; | |
| 491 | + | wdGoToHeading = 11; | |
| 492 | + | wdGoToLine = 3; | |
| 493 | + | wdGoToObject = 9; | |
| 494 | + | wdGoToPage = 1; | |
| 495 | + | wdGoToPercent = 12; | |
| 496 | + | wdGoToProofreadingError = 15; | |
| 497 | + | wdGoToSection = 0; | |
| 498 | + | wdGoToSpellingError = 13; | |
| 499 | + | wdGoToTable = 2; | |
| 500 | + | ||
| 501 | + | // Klasse wdParagraphAlignment | |
| 502 | + | wdAlignParagraphCenter = 1; | |
| 503 | + | wdAlignParagraphDistribute = 4; | |
| 504 | + | wdAlignParagraphJustify = 3; | |
| 505 | + | wdAlignParagraphJustifyHi = 7; | |
| 506 | + | wdAlignParagraphJustifyLow = 8; | |
| 507 | + | wdAlignParagraphJustifyMed = 5; | |
| 508 | + | wdAlignParagraphLeft = 0; | |
| 509 | + | wdAlignParagraphRight = 2; | |
| 510 | + | wdAlignParagraphThaiJustify = 9; | |
| 511 | + | ||
| 512 | + | //Klasse wdRowAlignment | |
| 513 | + | wdAlignRowCenter = 1; | |
| 514 | + | wdAlignRowLeft = 0; | |
| 515 | + | wdAlignRowRight = 2; | |
| 516 | + | ||
| 517 | + | // Klasse wdOpenFormat | |
| 518 | + | wdOpenFormatAllWord = 6; | |
| 519 | + | wdOpenFormatAuto = 0; | |
| 520 | + | wdOpenFormatDocument = 1; | |
| 521 | + | wdOpenFormatEncodedText = 5; | |
| 522 | + | wdOpenFormatRTF = 3; | |
| 523 | + | wdOpenFormatTemplate = 2; | |
| 524 | + | wdOpenFormatText = 4; | |
| 525 | + | wdOpenFormatUnicodeText = 5; | |
| 526 | + | wdOpenFormatWebPages = 7; | |
| 527 | + | wdOpenFormatXML = 8; | |
| 528 | + | ||
| 529 | + | // Klasse WdSaveOptions | |
| 530 | + | wdDoNotSaveChanges = 0; | |
| 531 | + | wdPromptToSaveChanges = -2; | |
| 532 | + | wdSaveChanges = -1; | |
| 533 | + | ||
| 534 | + | // Klasse WdCountry | |
| 535 | + | wdArgentina = 54; | |
| 536 | + | wdBrazil = 55; | |
| 537 | + | wdCanada = 2; | |
| 538 | + | wdChile = 56; | |
| 539 | + | wdChina = 86; | |
| 540 | + | wdDenmark = 45; | |
| 541 | + | wdFinland = 358; | |
| 542 | + | wdFrance = 33; | |
| 543 | + | wdGermany = 49; | |
| 544 | + | wdIceland = 345; | |
| 545 | + | wdItaly = 39; | |
| 546 | + | wdJapan = 81; | |
| 547 | + | wdKorea = 82; | |
| 548 | + | wdLatinAmerica = 3; | |
| 549 | + | wdMexico = 52; | |
| 550 | + | wdNetherlands = 31; | |
| 551 | + | wdNorway = 47; | |
| 552 | + | wdPeru = 51; | |
| 553 | + | wdSpain = 34; | |
| 554 | + | wdSweden = 46; | |
| 555 | + | wdTaiwan = 886; | |
| 556 | + | wdUK = 44; | |
| 557 | + | wdUS = 1; | |
| 558 | + | wdVenezuela = 58; | |
| 559 | + | ||
| 560 | + | // Klasse WdUnits | |
| 561 | + | wdCell = 12; | |
| 562 | + | wdCharacter = 1; | |
| 563 | + | wdCharacterFormatting = 13; | |
| 564 | + | wdColumn = 9; | |
| 565 | + | wdItem = 16; | |
| 566 | + | wdLine = 5; | |
| 567 | + | wdParagraph = 4; | |
| 568 | + | wdParagraphFormatting = 14; | |
| 569 | + | wdRow = 10; | |
| 570 | + | wdScreen = 7; | |
| 571 | + | wdSection = 8; | |
| 572 | + | wdSentence = 3; | |
| 573 | + | wdStory = 6; | |
| 574 | + | wdTable = 15; | |
| 575 | + | wdWindow = 11; | |
| 576 | + | wdWord = 2; | |
| 577 | + | ||
| 578 | + | implementation | |
| 579 | + | ||
| 580 | + | end. | |
| 581 | + | ``` | |
| 582 | + | ||
| 583 | + | --- | |
| 584 | + | *From the Free Pascal wiki, page "WordAutomation/de", as it stood on 2022-09-11 after a change by Wp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
