{"id":780,"date":"2008-05-26T20:08:03","date_gmt":"2008-05-26T20:08:03","guid":{"rendered":"http:\/\/6teen.ru\/?p=519"},"modified":"2008-05-26T20:08:03","modified_gmt":"2008-05-26T20:08:03","slug":"1044","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=780","title":{"rendered":"\u041a\u0430\u043a \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 MS Word \u0432 TStringGrid"},"content":{"rendered":"<p>\u041a\u0430\u043a \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 MS Word \u0432 TStringGrid<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u041a\u0430\u043a \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 MS Word \u0432 TStringGrid\n\nuses\ncomobj;\n\nprocedure tform1.button1click(sender: tobject);\nconst\naworddoc = 'c:xyztesttable.doc';\nvar\nmsword, table: olevariant;\nirows, icols, igridrows, jgridcols, inumtables, itablechosen: integer;\ncelltext: string;\ninputstring: string;\nbegin\ntry\nmsword := createoleobject('word.application');\nexcept\n\/\/ error....\nexit;\nend;\n\ntry\nmsword.visible := false;\nmsword.documents.open(aworddoc);\n\n\/\/ get number of tables in document\ninumtables := msword.activedocument.tables.count;\n\ninputstring := inputbox(inttostr(inumtables) +\n' tables in word document', 'please enter table number', '1');\n\/\/ todo: validate string for integer, range...\nitablechosen := strtoint(inputstring);\n\n\/\/ access table\ntable := msword.activedocument.tables.item(itablechosen);\n\/\/ get dimensions of table\nicols := table.rows.count;\nirows := table.columns.count;\n\/\/ adjust stringgrid columns\nstringgrid1.rowcount := icols;\nstringgrid1.colcount := irows + 1;\n\n\/\/ loop through cells\nfor igridrows := 1 to irows do\nfor jgridcols := 1 to icols do\nbegin\ncelltext := table.cell(jgridcols, igridrows).range.formattedtext;\nif not varisempty(celltext) then\nbegin\n\/\/ remove tabs\ncelltext := stringreplace(celltext,\n#$d, '', [rfreplaceall]);\n\/\/ remove linebreaks\ncelltext := stringreplace(celltext, #$7, '', [rfreplaceall]);\n\n\/\/ fill stringgrid\nstringgrid1.cells[igridrows, jgridcols] := celltext;\nend;\nend;\n\/\/..\nfinally\nmsword.quit;\nend;\nend;\n\n\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: http:\/\/www.swissdelphicenter.ch\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u0430\u043a \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 MS Word \u0432 TStringGrid<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[416,432],"tags":[1200,1925,1009,1872],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/780"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=780"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/780\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=780"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}