本文介绍了从word .dot导出到.rtf后,RTF文本中添加了太多未使用的样式标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个用vba完成的单词模板,在特定的键盘事件中,我会在文档的BOOKMARKS中对用户进行更改,以便在DB中更新它们。 问题是一些数据必须用它们的样式(粗体,斜体,颜色,对齐)保存,但是当我尝试复制书签的内容并获取它的rtf内容时,会添加许多不必要的标签! 我不想要纯文本,我想保留必要的样式标签,但我必须删除其余的,因为我不可能将所有这些数据保存在DB中巨大!! 这是我正在使用和获取的一个示例: 书签,它写成 * test1 在粗体中,当我从富文本框中取出时,我得到的是以下字符串: < small> { \rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033 {{\fonttbl \f0\fnil\fcharset0宋体;} {\f1 \ froman \fprq2 \fcharset0 Times New Roman;}}< br /> \ viewkind4 \\\\\\\\\\\\\\ \ b0\f1\par< br /> }< / small> 但是在我使用我的代码之后(我必须使用它),我得到的是: < small> {\rtf1\adeflang1025 \\ \\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0 {\fonttbl {\f0\\ \\ fbidi \froman\fcharset0\fprq2 {\ * \ panose 02020603050405020304} Times New Roman;} {\f34\fbidi \froman\fcharset0\fprq2 {\ * \ panose 02040503050406030204}坎布里亚数学;}<峰; br /> {\f37\fbidi \fswiss\fcharset0\fprq2 {\ * \panose 020f0502020204030204}宋体;} {\flomajor \\ f31500 \fbidi \froman\fcharset0\fprq2 {\ * \ panose 02020603050405020304} Times New Roman;}< br /> {\fdbmajor\f31501\fbidi \froman \ fcharset0\fprq2 {\ * \ panose 02020603050405020304} Times New Roman;} {\\\\\\\\\\\\\\\\\\ }< BR /> {\fbimajor\f31503\fbidi \froman\fcharset0\fprq2 {\ * \panose 02020603050405020304}宋体;} {\flominor\f31504 \fbidi \froman\fcharset0\fprq2 {\ * \panose 02020603050405020304}宋体;}< BR /> {\fdbminor\f31505\fbidi \froman\ fcharset0\fprq2 {\ * \panose 02020603050405020304}宋体;} {\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2 {\ * \panose 020f0502020204030204}宋体;}< ; br /> {\fbiminor \ f31507\fbidi \froman\fcharset0\fprq2 {\ * \panose 02020603050405020304}宋体;} {\f41\fbidi \froman\fcharset238\fprq2宋体CE;} { \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ ;} {\f45\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;} {\\\\\\\\\\\\\\\\\\\\\\ \\f47\fbidi \froman\fcharset178\fprq2 Times New Roman字体(阿拉伯);}<峰; br /> {\f48\fbidi \froman\fcharset186\fprq2 Times New Roman字体波罗的海;} {\f49\fbidi \froman\fcharset163\fprq2 Times New Roman字体(越南);} {\f381\fbidi \froman\fcharset238\fprq2坎布里亚数学CE;} {\\ \\ f382 \ fbidi \froman \fcharset204 \ fprq2 Cambria Math Cy R等}<峰; br /> {\f384\fbidi \froman\fcharset161\fprq2坎布里亚数学希腊语;} {\f385\fbidi \froman\fcharset162\fprq2坎布里亚Math Tur;} {\\\\\\\\\\\\\\\\\\\\ {{{{{{{登记/> {\f411\fbidi \fswiss\fcharset238\fprq2宋体CE;} {\f412\fbidi \fswiss\fcharset204\fprq2宋体CYR;} {\ f414\fbidi \fswiss\fcharset161\fprq2宋体希腊语;} {\f415\fbidi \fswiss\fcharset162\fprq2宋体图尔;}<峰; br /> {\f418 \ fbidi \fswiss \fcharset186 \ fprq2 Calibri Baltic;} {\\\ f419 \ fbidi \fswiss \fcharset163 \ fprq2 Calibri(越南语);} {\\\\\\\\\\\\\\ froman\fcharset238\fprq2 Times New Roman CE;}< br /> {\flomajor\\ f31509\fbidi \froman\fcharset204\fprq2宋体CYR;} {\flomajor\f31511\fbidi \froman\fcharset161\fprq2宋体希腊;} {\flomajor\ f31512\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}< br /> {\\\\\\\\\\\\\\\\\\\\\\ (希伯来文);} {\flomajor\f31514\fbidi \froman\fcharset178\fprq2 Times New Roman字体(阿拉伯语);} {\flomajor\f31515\fbidi \froman\fcharset186\ fprq2 Times New Roman字体巴尔;}<峰; br /> {\flomajor\f31516\fbidi \froman\fcharset163\fprq2 Times New Roman字体(越南);} {\fdbmajor\f31518 \fbidi \froman\fcharset238\fprq2宋体CE;} {\fdbmajor\f31519\fbidi \froman\fcharset204\fprq2宋体CYR;}< BR /> {\fdbmajor\f31521\fbidi \\ froman\fcharset161\fprq2宋体希腊;} {\fdbmajor\f31522\fbidi \froman\fcharset162\fprq2宋体图尔;} {\fdbmajor\f31523\fbidi \ froman\fcharset177\fprq2 Times New Roman字体(希伯来语);}<峰; br /> {\fdbmajor\f31524\fbidi \froman\fcharset178\fprq2 Times New Roman字体(阿拉伯); } {\fdbmajor\f31525\fbidi \froman\fcharset186\fprq2宋体波罗的海;} {\fdbmajor\f31526\fbidi \froman\fcharset163\fprq2 Times New Roman字体(越南);}<峰; br /> {\fhimajor\f31528\fbidi \froman\fcharset238\fprq2坎布里亚CE;} {\fhimajor\f31529\fbidi \froman\ fcharset204\fprq2坎布里亚CYR;} {\fhimajor\f31531\fbidi \froman\fcharset161\fprq2坎布里亚希腊;} {\fhimajor\f31532\fbidi \froman\fcharset162\fprq2 Cambria Tur;}< br /> {\fhimajor\f31535\fbidi \froman\fcharset186\fprq2坎布里亚巴尔;} {\fhimajor\f31536\fbidi \froman\fcharset163\fprq2坎布里亚(越南) ;} {\fbimajor\f31538\fbidi \froman\fcharset238\fprq2宋体CE;}< BR /> {\fbimajor\f31539\fbidi \froman\\ \\fcharset204\fprq2宋体CYR;} {\fbimajor\f31541\fbidi \froman\fcharset161\fprq2宋体希腊;} {\fbimajor\f31542\fbidi \froman\\ \\fcharset162\fprq2 Times New Roman字体图尔;}<峰; br /> {\fbimajor\f31543\fbidi \froman\fcharset177\fprq2 Times New Roman字体(希伯来语);} {\ fbimajor\f31544\fbidi \froman\fcharset178\fprq2 Times New Roman字体(阿拉伯);} {\fbimajor\f31545\fbidi \froman\fcharset186\fprq2 Times New Roman字体巴尔;}< ; br /> {\ fbimajor\f31546 \\ fbidi \froman\fcharset163\fprq2 Times New Roman字体(越南);} {\flominor\f31548\fbidi \froman\fcharset238\fprq2宋体CE;} {\flominor\f31549 \fbidi \froman\fcharset204\fprq2宋体CYR;}< BR /> {\flominor\f31551\fbidi \froman\fcharset161\fprq2宋体希腊;} {\flominor\f31552\fbidi \froman\fcharset162\fprq2宋体图尔;} {\flominor\f31553\fbidi \froman\fcharset177\fprq2 Times New Roman字体(希伯来语);}<峰; br /> {\flominor\f31554\fbidi \froman\fcharset178\fprq2 Times New Roman字体(阿拉伯);} {\flominor\f31555\fbidi \ froman \fcharset186 \ fprq2 Times New Roman Baltic;} {\\\\\\\\\\\\\\\\\\\\\\\\\ b {\fdbminor \f31558 \ fbidi \ froman\fcharset238\fprq2宋体CE;} {\fdbminor\f31559\fbidi \froman\fcharset204\fprq2宋体CYR;} {\fdbminor\f31561\fbidi \ froman \fcharset161\fprq2 Times New Roman Greek;}< br /> {\\\\\\\\\\\\\\\\\\\\\\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ fdbminor\f31563\fbidi \froman\fcharset177\fprq2 Times New Roman字体(希伯来文);} {\fdbminor\f31564\fbidi \froman\fcharset178\fprq2 Times New Roman字体(阿拉伯语); }<峰; br /> {\fdbminor\f31565\fbidi \froman\fcharset186\fprq2 Times New Roman字体巴尔;} {\fdbminor\f31566\fbidi \froman\ fcharset163 \ fprq2 Times New Roman(越南语);} {\\\\\\\\\\\\ f31569 \fbidi \fswiss \fcharset204 \ afpr Q2宋体CYR;} {\fhiminor\f31571\fbidi \fswiss\fcharset161\fprq2宋体希腊语;} {\fhiminor\f31572\fbidi \fswiss\fcharset162\fprq2宋体图尔; }<峰; br /> {\fhiminor\f31575\fbidi \fswiss\fcharset186\fprq2宋体巴尔;} {\fhiminor\f31576\fbidi \fswiss\fcharset163\\ \\fprq2宋体(越南);} {\fbiminor\f31578\fbidi \froman\fcharset238\fprq2 Times New Roman字体CE;}<峰; br /> {\fbiminor\f31579\\ \\fbidi \froman\fcharset204\fprq2宋体CYR;} {\fbiminor\f31581\fbidi \froman\fcharset161\fprq2宋体希腊;} {\fbiminor\f31582\\ \\ fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}< br /> {\\\\\\\\\ );}} {\ fbiminor \f31584 \ fbidi \\ \\froman\fcharset178\fprq2 Times New Roman字体(阿拉伯);} {\fbiminor\f31585\fbidi \froman\fcharset186\fprq2 Times New Roman字体巴尔;}<峰; br /> {\fbiminor\f31586\fbidi \froman\fcharset163 \fprq2 Times New Roman(越南语);}} {\ colortbl; \\\green0 \ blue0; \\\\ \\blue255; \red0\green255\blue255; \red0\green255\blue0; \red255\green0\blue255; \red255\green0\blue0; \red255\green255\\ \\ blue0;< br /> \red255 \green255 \ blue255; \\\ green0 \ blue128; \\\ green128 \ blue128; \\\\\\\\\\\\\\\\ blue0; \red128\green0\blue128; \red128\green0\blue0; \red128\green128\blue0; \red128\green128\blue128; \red192\green192\ blue192;} {\ * \defchp< br /> \fs22 \ loch \ af31506 \ h ich\af31506\dbch\af31505} {\ * \defpap \ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\ faauto\adjustright\rin0\lin0\itap0} \\\oqfpromote {\stylesheet {\ql \li0\ri0\sa200\sl276\slmult1<峰; br /> \ widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\\ \\lang1033\langfe1033\loch\f31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp1033 \snext0 \sqformat \spriority0正常;}<峰; br /> {\ * \cs10 \additive \ssemihidden \sunhideused \spriority1默认段落字体;} {\ * LT峰; br /> \ts11\tsrowd\trftsWidthB3\\ \\trpaddl108\trpaddr108\trpadd fl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\\ \\ri0\sa200\sl276\slmult1<峰; br /> \widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\\ \\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang1033\langfe1033\loch\f31506\hich\af31506\dbch\af31505\cgrid\langnp1033 \langfenp1033 \snext11 \ssemihidden \sunhideused< br /> 普通表;}} {\ * \\\ idtbl \rsid664789 \ rsid11549567} {\\\\\\\\\\\\\\\\ \mbrkBinSub0\msmallFrac0\mdispDef1\mlMargin0\mrMargin0\mdefJc1\mwrapIndent1440\mintLim0\mnaryLim1} {\info {\version0} {\edmin s0} {\\\ofpages1} {\\\ofwords0} {\ nofofrsrs6}< br /> {\ * \ company OSD} {\ nofofrsrs6}} {\vern49167}} {\ * \xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}}\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect <峰; br /> \widowctrl\ftnbj\aenddoc\trackmoves0\trackformatting1\donotembedsysfont1\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\ showxmlerrors1 \\\oxlattoyen< br /> \expshrtn \\\oultrlspc\dntblnsbdb \\\ospaceforul \formshade \ horzdoc \dgmargin \dghspace180 \dgvspace180 \dghorigin1701 \dgvorigin1984 \dghshow1 \ dgvshow1< br /> \ jexpand \pgbrdrhead \pgbrdrfoot \splytwnine \ftnlytwnine \htmautsp \ nnnnttjtbl \ us eltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\\\obrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct\asianbrkrule\rsidroot664789< br /> \ newtblstyruls\\\ogrowautofit\usenormstyforlist \ noindnmbrts\felnbrelev\\\ocxsptable\intlsweleven\\\oafcnsttbl\afelev\utinl\hwelev\spltpgpar \ notcvasp \ notbrkcnstfrctbl \ notvatxbx \ krnprsnet \ ancachedcolbal \\\ouicompat \ fet0 {\ * \wgrffmtfilter 2450}<峰; br /> \\\ofeaturethrottle1\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\ * \ pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta。}} {\ * \pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta。}} {\ *。 \ pnseclvl3< br /> \pndec\pnstart1 \ pnindent720 \ pnh昂{\pntxta。}} {\ * \pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta)}} {\ * \pnseclvl5\pndec\pnstart1\pnindent720 \pnhang {\pntxtb(} {\pntxta)}} {\ * \pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb(} {\pntxta)}}<登记/> {\ * \pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb(} {\pntxta)}} {\ * \pnseclvl8\pnlcltr\\ \\ pnstart1 \ pnindent720 \pnhang {\\\ pntxtb(} {\ pntxta)}} {\ * \ pnseclvl9 \pnlcrm \ pnstart1 \ pnindent720 \pnhang {\\\ pntxtb(} {\\\ pntxta )}} \pard\plain \ltrpar<峰; br /> \ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum \ faauto \adjustright \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ fcs0 \fs22\lang1033\langfe1033\loch\af31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp1033 {< br /> \ rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid664789\charrsid15300069 \hich\af0\dbch\af31505\loch\\ \\ f0 * test1 } {\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid11549567< br /> \ par} {\ * \ themedata 504b030414000600080000002100e9de0fbfff0000001c020000130000005b436f6e74656e745f54797065735d2e786d6cac91cb4ec3301045f748fc83e52d4a ...< / small>以及更多 如您所见,过多的未使用信息。 请尽力帮助我解决这个问题,这非常重要:( 我的代码: Sub 测试() Dim ad 作为文档 设置 ad = ActiveDocument Dim bm As 书签 dim rtf as 字符串 对于 每个 bm 在 ad.Bookmarks 设置 rngread = bm.Range rngread。结束 = rngread。结束 - 1 ' 用于保护书签的1字体空间 rtf = GetRTFtext(rngread) 下一步 结束 Sub Func GetRTFtext(rngread 作为范围)作为 字符串 Dim RTFText 作为 字符串 Dim TempFile 作为 字符串 TempFile = C:/ Temp / tmp0859&日(现在)&月(现在)&年(现在)&小时(现在)&分钟(现在)&第二(现在)& 。rtf rngread.ExportFragment TempFile,wdFormatRTF Dim objFSO As 新 FileSystemObject Dim objTextStream As TextStream 设置 objTextStream = objFSO.OpenTextFile(临时文件,ForReading的) RTFText = objTextStream.ReadAll objTextStream.Close 如果 objFSO.FileExists(临时文件)然后 objFSO.DeleteFile TempFile GetRTFtext = RTFText 结束 功能 解决方案 好的我90%肯定除了加载文本之外别无他法临时的RichTextBox控件然后从中获取它们,太糟糕了! Hi,I have a word template done with vba, and on a specific keyboard event I take changes done by user within document's BOOKMARKS to update them in DB.The problem is that some data has to be saved with their styling (Bold, Italic, Colors, Alignment), but when I try to copy the content of a bookmark and get the rtf content of it, a lot of unnecessary tags are added!I don't want the plain text, I want to keep the necessary style tags, but I have to remove the rest, because it is impossible for me to save all this data in DB, too huge!!This is a sample of what I'm using and getting:in a bookmark, it is written "*test1" in Bold, when I take it as from a rich text box, what I get is the following string:"<small>{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset0 Times New Roman;}}<br />\viewkind4\uc1\pard\ltrpar\b\f0\fs24 *test1\b0\f1\par<br />}</small>"but after I use my piece of code (that I have to use it), what I get is:"<small>{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria Math;}<br />{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\flomajor\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}<br />{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhimajor\f31502\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria;}<br />{\fbimajor\f31503\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\flominor\f31504\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}<br />{\fdbminor\f31505\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}<br />{\fbiminor\f31507\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f41\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\f42\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}<br />{\f44\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\f45\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\f46\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f47\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}<br />{\f48\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\f49\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f381\fbidi \froman\fcharset238\fprq2 Cambria Math CE;}{\f382\fbidi \froman\fcharset204\fprq2 Cambria Math Cyr;}<br />{\f384\fbidi \froman\fcharset161\fprq2 Cambria Math Greek;}{\f385\fbidi \froman\fcharset162\fprq2 Cambria Math Tur;}{\f388\fbidi \froman\fcharset186\fprq2 Cambria Math Baltic;}{\f389\fbidi \froman\fcharset163\fprq2 Cambria Math (Vietnamese);}<br />{\f411\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}{\f412\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}{\f414\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\f415\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}<br />{\f418\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;}{\f419\fbidi \fswiss\fcharset163\fprq2 Calibri (Vietnamese);}{\flomajor\f31508\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}<br />{\flomajor\f31509\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\flomajor\f31511\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\flomajor\f31512\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}<br />{\flomajor\f31513\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\flomajor\f31514\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\flomajor\f31515\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}<br />{\flomajor\f31516\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fdbmajor\f31518\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fdbmajor\f31519\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}<br />{\fdbmajor\f31521\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fdbmajor\f31522\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fdbmajor\f31523\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}<br />{\fdbmajor\f31524\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fdbmajor\f31525\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fdbmajor\f31526\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}<br />{\fhimajor\f31528\fbidi \froman\fcharset238\fprq2 Cambria CE;}{\fhimajor\f31529\fbidi \froman\fcharset204\fprq2 Cambria Cyr;}{\fhimajor\f31531\fbidi \froman\fcharset161\fprq2 Cambria Greek;}{\fhimajor\f31532\fbidi \froman\fcharset162\fprq2 Cambria Tur;}<br />{\fhimajor\f31535\fbidi \froman\fcharset186\fprq2 Cambria Baltic;}{\fhimajor\f31536\fbidi \froman\fcharset163\fprq2 Cambria (Vietnamese);}{\fbimajor\f31538\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}<br />{\fbimajor\f31539\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fbimajor\f31541\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fbimajor\f31542\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}<br />{\fbimajor\f31543\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fbimajor\f31544\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fbimajor\f31545\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}<br />{\fbimajor\f31546\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\flominor\f31548\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\flominor\f31549\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}<br />{\flominor\f31551\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\flominor\f31552\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\flominor\f31553\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}<br />{\flominor\f31554\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\flominor\f31555\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\flominor\f31556\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}<br />{\fdbminor\f31558\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fdbminor\f31559\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fdbminor\f31561\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}<br />{\fdbminor\f31562\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fdbminor\f31563\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fdbminor\f31564\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}<br />{\fdbminor\f31565\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fdbminor\f31566\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fhiminor\f31568\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}<br />{\fhiminor\f31569\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}{\fhiminor\f31571\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\fhiminor\f31572\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}<br />{\fhiminor\f31575\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;}{\fhiminor\f31576\fbidi \fswiss\fcharset163\fprq2 Calibri (Vietnamese);}{\fbiminor\f31578\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}<br />{\fbiminor\f31579\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fbiminor\f31581\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fbiminor\f31582\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}<br />{\fbiminor\f31583\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fbiminor\f31584\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fbiminor\f31585\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}<br />{\fbiminor\f31586\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;<br />\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\*\defchp <br />\fs22\loch\af31506\hich\af31506\dbch\af31505 }{\*\defpap \ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 }\noqfpromote {\stylesheet{\ql \li0\ri0\sa200\sl276\slmult1<br />\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang1033\langfe1033\loch\f31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp1033 \snext0 \sqformat \spriority0 Normal;}<br />{\*\cs10 \additive \ssemihidden \sunhideused \spriority1 Default Paragraph Font;}{\*<br />\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblind0\tblindtype3\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\sa200\sl276\slmult1<br />\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang1033\langfe1033\loch\f31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp1033 \snext11 \ssemihidden \sunhideused <br />Normal Table;}}{\*\rsidtbl \rsid664789\rsid11549567}{\mmathPr\mmathFont34\mbrkBin0\mbrkBinSub0\msmallFrac0\mdispDef1\mlMargin0\mrMargin0\mdefJc1\mwrapIndent1440\mintLim0\mnaryLim1}{\info{\version0}{\edmins0}{\nofpages1}{\nofwords0}{\nofchars6}<br />{\*\company OSD}{\nofcharsws6}{\vern49167}}{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}}\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\gutter0\ltrsect <br />\widowctrl\ftnbj\aenddoc\trackmoves0\trackformatting1\donotembedsysfont1\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\showxmlerrors1\noxlattoyen<br />\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1701\dgvorigin1984\dghshow1\dgvshow1<br />\jexpand\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct\asianbrkrule\rsidroot664789<br />\newtblstyruls\nogrowautofit\usenormstyforlist\noindnmbrts\felnbrelev\nocxsptable\indrlsweleven\noafcnsttbl\afelev\utinl\hwelev\spltpgpar\notcvasp\notbrkcnstfrctbl\notvatxbx\krnprsnet\cachedcolbal \nouicompat \fet0{\*\wgrffmtfilter 2450}<br />\nofeaturethrottle1\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3<br />\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}<br />{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain \ltrpar<br />\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang1033\langfe1033\loch\af31506\hich\af31506\dbch\af31505\cgrid\langnp1033\langfenp1033 {<br />\rtlch\fcs1 \ab\af0\afs24 \ltrch\fcs0 \b\f0\fs24\insrsid664789\charrsid15300069 \hich\af0\dbch\af31505\loch\f0 *test1}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid11549567 <br />\par }{\*\themedata 504b030414000600080000002100e9de0fbfff0000001c020000130000005b436f6e74656e745f54797065735d2e786d6cac91cb4ec3301045f748fc83e52d4a ...</small>" and much moreAs you can see, too much unused information.Please do your best to help me fix this, it's really important :(My Code:Sub Test()Dim ad As DocumentSet ad = ActiveDocumentDim bm As Bookmarkdim rtf as StringFor Each bm In ad.Bookmarks Set rngread = bm.Range rngread.End = rngread.End - 1 'for the 1 font space protecting the bookmark rtf = GetRTFtext(rngread)NextEnd SubFunction GetRTFtext(rngread As Range) As String Dim RTFText As String Dim TempFile As String TempFile = "C:/Temp/tmp0859" & Day(Now) & Month(Now) & Year(Now) & Hour(Now) & Minute(Now) & Second(Now) & ".rtf" rngread.ExportFragment TempFile, wdFormatRTF Dim objFSO As New FileSystemObject Dim objTextStream As TextStream Set objTextStream = objFSO.OpenTextFile(TempFile, ForReading) RTFText = objTextStream.ReadAll objTextStream.Close If objFSO.FileExists(TempFile) Then objFSO.DeleteFile TempFile GetRTFtext = RTFTextEnd Function 解决方案 Ok I'm 90% sure there is no other way than loading the text a temporary RichTextBox control then get them from it, too bad ! 这篇关于从word .dot导出到.rtf后,RTF文本中添加了太多未使用的样式标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 23:12