Thank u very much. Thats works perfectly fine.
Working with files in VB 6.0
Collapse
X
-
Originally posted by amitpThank u very much. Thats works perfectly fine.
You really should try playing around with things in these situations, you'll learn heaps. All I did was create a simple test document in Word, with a table. Then I put the cursor at the end of the document, told Word to record a macro, then I moved the cursor back to where I wanted it. All I had to do then was copy the code from the macro it created for me. :DComment
-
Accoding to you i tried for the code that deletes an empty line but can i do this?
Can i read the whole document line by line , thereby copying the line content into a string recording the line number, then checking for the length of string. If it comes to zero(0), then that is a empty line and then delete the line. I tried the below code which moves the cursor up from the end of the file by one line until the first line or the top of the file comes. During the cursor movement it gives the line number.The problem is i'm not getting the condition to check for the empty line. plz look into this. Thanking You
Do Until (linecount = 1)
wrdDoc.Applicat ion.Selection.M oveUp Unit:=wdLine, Count:=1, Extend:=wdMove
linecount = wrdDoc.Applicat ion.Selection.I nformation(wdFi rstCharacterLin eNumber)
wrdDoc.Applicat ion.Selection.D elete (This code deletes the line selected)
' End If
LoopComment
-
Sorry amitp, I haven't had a chance to look into either of these problems. Plus, I'm not very experienced in working with Word documents from VB.
I've just split both questions off into separate threads, so that they are likely to get a response from others who may not have seen this old one.Comment
-
I've some problem with WORD doc but i don't know the reason, need ur help.
U know that i'm replacing the field values(access datbse column names) in the DOC with the respective values(column values) from the Access databse. But when the text size exceeds a cell width , the text doesn't display i.e the text doesn't come(wrap) to a new line. But this is not the case when u type some text in the cell, i e. when u type some text in the cell and when the text length exceeds the cell width the text automatically wraps to new line. Why is the difference. I've mentioned the wraping text problem in a new thread and got the suggesstion to try WRODWRAP property of cell. But nothing happened. Could u tell me what can be done for this.Comment
-
Now starting with the issue to find and replace strings, it works fine. But at one point it gives a problem. When the replaced string is more than the cell width it is not displayed. Also when i single click on a replaced value the whole text is selected, that means after replacement it doesn't wrap into new line if the text size is large than the cell width. Bcoz i think it is treating it as field not text. i don't know the reason. But when i opened it in Notepad i got something.
{\rtf1\ansi\ans icpg1252\uc1\de ff0\stshfdbch0\ stshfloch0\stsh fhich0\stshfbi0 \deflang1033\de flangfe1033{\fo nttbl{\f0\froma n\fcharset0\fpr q2{\*\panose 020206030504050 20304}Times New Roman;}{\f1\fsw iss\fcharset0\f prq2{\*\panose 020b06040202020 20204}Arial;}
{\f36\fswiss\fc harset0\fprq2{\ *\panose 000000000000000 00000}KPN Sans{\*\falt Arial};}{\f177\ froman\fcharset 238\fprq2 Times New Roman CE;}{\f178\from an\fcharset204\ fprq2 Times New Roman Cyr;}{\f180\fro man\fcharset161 \fprq2 Times New Roman Greek;}
{\f181\froman\f charset162\fprq 2 Times New Roman Tur;}{\f182\fro man\fcharset177 \fprq2 Times New Roman (Hebrew);}{\f18 3\froman\fchars et178\fprq2 Times New Roman (Arabic);}{\f18 4\froman\fchars et186\fprq2 Times New Roman Baltic;}
{\f185\froman\f charset163\fprq 2 Times New Roman (Vietnamese);}{ \f187\fswiss\fc harset238\fprq2 Arial CE;}{\f188\fswi ss\fcharset204\ fprq2 Arial Cyr;}{\f190\fsw iss\fcharset161 \fprq2 Arial Greek;}{\f191\f swiss\fcharset1 62\fprq2 Arial Tur;}
{\f192\fswiss\f charset177\fprq 2 Arial (Hebrew);}{\f19 3\fswiss\fchars et178\fprq2 Arial (Arabic);}{\f19 4\fswiss\fchars et186\fprq2 Arial Baltic;}{\f195\ fswiss\fcharset 163\fprq2 Arial (Vietnamese);}} {\colortbl;\red 0\green0\blue0; \red0\green0\bl ue255;
\red0\green255\ blue255;\red0\g reen255\blue0;\ red255\green0\b lue255;\red255\ green0\blue0;\r ed255\green255\ blue0;\red255\g reen255\blue255 ;\red0\green0\b lue128;\red0\gr een128\blue128; \red0\green128\ blue0;\red128\g reen0\blue128;\ red128\green0\b lue0;
\red128\green12 8\blue0;\red128 \green128\blue1 28;\red192\gree n192\blue192;}{ \stylesheet{\ql \li0\ri0\widctl par\aspalpha\as pnum\faauto\adj ustright\rin0\l in0\itap0 \fs24\lang1033\ langfe1033\cgri d\langnp1033\la ngfenp1033 \snext0 Normal;}{\*\cs1 0 \additive
\ssemihidden Default Paragraph Font;}{\*\ts11\ tsrowd\trftsWid thB3\trpaddl108 \trpaddr108\trp addfl3\trpaddft 3\trpaddfb3\trp addfr3\tscellwi dthfts0\tsverta lt\tsbrdrt\tsbr drl\tsbrdrb\tsb rdrr\tsbrdrdgl\ tsbrdrdgr\tsbrd rh\tsbrdrv
\ql \li0\ri0\widctl par\aspalpha\as pnum\faauto\adj ustright\rin0\l in0\itap0 \fs20\lang1024\ langfe1024\cgri d\langnp1024\la ngfenp1024 \snext11 \ssemihidden Normal Table;}{\*\cs15 \additive \f1\fs16 \sbasedon10 \styrsid220190 CellTitel;}}
{\*\latentstyle s\lsdstimax156\ lsdlockeddef0}{ \*\rsidtbl \rsid220190}{\* \generator Microsoft Word 11.0.5604;}{\in fo{\title 01-11-2000 }{\author A113937}{\opera tor A113937}{\creat im\yr2007\mo3\d y9\hr14\min51}{ \revtim\yr2007\ mo3\dy9\hr14\mi n51}{\version1}
{\edmins0}{\nof pages1}{\nofwor ds5}{\nofchars3 3}{\*\company Atos Origin}{\nofcha rsws37}{\vern24 689}}\widowctrl \ftnbj\aenddoc\ noxlattoyen\exp shrtn\noultrlsp c\dntblnsbdb\no spaceforul\form shade\horzdoc\d gmargin\dghspac e180\dgvspace18 0\dghorigin1701
\dgvorigin1984\ dghshow1\dgvsho w1\jexpand\view kind4\viewscale 100\pgbrdrhead\ pgbrdrfoot\sply twnine\ftnlytwn ine\htmautsp\no lnhtadjtbl\usel tbaln\alntblind \lytcalctblwd\l yttblrtgr\lnbrk rule\nobrkwrptb l\snaptogridinc ell\allowfielde ndsel\wrppunct
\asianbrkrule\r sidroot220190\n ewtblstyruls\no growautofit \fet0\sectd \linex0\endnher e\sectlinegrid3 60\sectdefaultc l\sectrsid22961 09\sftnbj {\*\pnseclvl1\p nucrm\pnstart1\ pnindent720\pnh ang {\pntxta .}}{\*\pnseclvl 2\pnucltr\pnsta rt1\pnindent720 \pnhang
{\pntxta .}}{\*\pnseclvl 3\pndec\pnstart 1\pnindent720\p nhang {\pntxta .}}{\*\pnseclvl 4\pnlcltr\pnsta rt1\pnindent720 \pnhang {\pntxta )}}{\*\pnseclvl 5\pndec\pnstart 1\pnindent720\p nhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl 6\pnlcltr\pnsta rt1\pnindent720 \pnhang
{\pntxtb (}{\pntxta )}}{\*\pnseclvl 7\pnlcrm\pnstar t1\pnindent720\ pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl 8\pnlcltr\pnsta rt1\pnindent720 \pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl 9\pnlcrm\pnstar t1\pnindent720\ pnhang {\pntxtb (}{\pntxta )}}\pard\plain
\ql \li0\ri0\widctl par\aspalpha\as pnum\faauto\adj ustright\rin0\l in0\itap0 \fs24\lang1033\ langfe1033\cgri d\langnp1033\la ngfenp1033 {\field\fldedit {\*\fldinst {\cs15\i\f36\fs 14\cf1\insrsid2 20190 MACROBUTTON QueryVeld 01-11-2000 }}{\fldrslt }}{
\insrsid220190
\par
\par }}
the bold letter filed code remains and it is treated as field, so we need to remove the field code and just keep the column name only. how can i do that.Comment
-
Hello... I think you should read the rtf as text file , search for your keyword, then you can replace it. Of course you need an output file for writing.
Have you already tried this kind of approach ?
Bye,
diSangro
Originally posted by amitpNow starting with the issue to find and replace strings, it works fine. But at one point it gives a problem. When the replaced string is more than the cell width it is not displayed. Also when i single click on a replaced value the whole text is selected, that means after replacement it doesn't wrap into new line if the text size is large than the cell width. Bcoz i think it is treating it as field not text. i don't know the reason. But when i opened it in Notepad i got something.
{\rtf1\ansi\ans icpg1252\uc1\de ff0\stshfdbch0\ stshfloch0\stsh fhich0\stshfbi0 \deflang1033\de flangfe1033{\fo nttbl{\f0\froma n\fcharset0\fpr q2{\*\panose 020206030504050 20304}Times New Roman;}{\f1\fsw iss\fcharset0\f prq2{\*\panose 020b06040202020 20204}Arial;}
{\f36\fswiss\fc harset0\fprq2{\ *\panose 000000000000000 00000}KPN Sans{\*\falt Arial};}{\f177\ froman\fcharset 238\fprq2 Times New Roman CE;}{\f178\from an\fcharset204\ fprq2 Times New Roman Cyr;}{\f180\fro man\fcharset161 \fprq2 Times New Roman Greek;}
{\f181\froman\f charset162\fprq 2 Times New Roman Tur;}{\f182\fro man\fcharset177 \fprq2 Times New Roman (Hebrew);}{\f18 3\froman\fchars et178\fprq2 Times New Roman (Arabic);}{\f18 4\froman\fchars et186\fprq2 Times New Roman Baltic;}
{\f185\froman\f charset163\fprq 2 Times New Roman (Vietnamese);}{ \f187\fswiss\fc harset238\fprq2 Arial CE;}{\f188\fswi ss\fcharset204\ fprq2 Arial Cyr;}{\f190\fsw iss\fcharset161 \fprq2 Arial Greek;}{\f191\f swiss\fcharset1 62\fprq2 Arial Tur;}
{\f192\fswiss\f charset177\fprq 2 Arial (Hebrew);}{\f19 3\fswiss\fchars et178\fprq2 Arial (Arabic);}{\f19 4\fswiss\fchars et186\fprq2 Arial Baltic;}{\f195\ fswiss\fcharset 163\fprq2 Arial (Vietnamese);}} {\colortbl;\red 0\green0\blue0; \red0\green0\bl ue255;
\red0\green255\ blue255;\red0\g reen255\blue0;\ red255\green0\b lue255;\red255\ green0\blue0;\r ed255\green255\ blue0;\red255\g reen255\blue255 ;\red0\green0\b lue128;\red0\gr een128\blue128; \red0\green128\ blue0;\red128\g reen0\blue128;\ red128\green0\b lue0;
\red128\green12 8\blue0;\red128 \green128\blue1 28;\red192\gree n192\blue192;}{ \stylesheet{\ql \li0\ri0\widctl par\aspalpha\as pnum\faauto\adj ustright\rin0\l in0\itap0 \fs24\lang1033\ langfe1033\cgri d\langnp1033\la ngfenp1033 \snext0 Normal;}{\*\cs1 0 \additive
\ssemihidden Default Paragraph Font;}{\*\ts11\ tsrowd\trftsWid thB3\trpaddl108 \trpaddr108\trp addfl3\trpaddft 3\trpaddfb3\trp addfr3\tscellwi dthfts0\tsverta lt\tsbrdrt\tsbr drl\tsbrdrb\tsb rdrr\tsbrdrdgl\ tsbrdrdgr\tsbrd rh\tsbrdrv
\ql \li0\ri0\widctl par\aspalpha\as pnum\faauto\adj ustright\rin0\l in0\itap0 \fs20\lang1024\ langfe1024\cgri d\langnp1024\la ngfenp1024 \snext11 \ssemihidden Normal Table;}{\*\cs15 \additive \f1\fs16 \sbasedon10 \styrsid220190 CellTitel;}}
{\*\latentstyle s\lsdstimax156\ lsdlockeddef0}{ \*\rsidtbl \rsid220190}{\* \generator Microsoft Word 11.0.5604;}{\in fo{\title 01-11-2000 }{\author A113937}{\opera tor A113937}{\creat im\yr2007\mo3\d y9\hr14\min51}{ \revtim\yr2007\ mo3\dy9\hr14\mi n51}{\version1}
{\edmins0}{\nof pages1}{\nofwor ds5}{\nofchars3 3}{\*\company Atos Origin}{\nofcha rsws37}{\vern24 689}}\widowctrl \ftnbj\aenddoc\ noxlattoyen\exp shrtn\noultrlsp c\dntblnsbdb\no spaceforul\form shade\horzdoc\d gmargin\dghspac e180\dgvspace18 0\dghorigin1701
\dgvorigin1984\ dghshow1\dgvsho w1\jexpand\view kind4\viewscale 100\pgbrdrhead\ pgbrdrfoot\sply twnine\ftnlytwn ine\htmautsp\no lnhtadjtbl\usel tbaln\alntblind \lytcalctblwd\l yttblrtgr\lnbrk rule\nobrkwrptb l\snaptogridinc ell\allowfielde ndsel\wrppunct
\asianbrkrule\r sidroot220190\n ewtblstyruls\no growautofit \fet0\sectd \linex0\endnher e\sectlinegrid3 60\sectdefaultc l\sectrsid22961 09\sftnbj {\*\pnseclvl1\p nucrm\pnstart1\ pnindent720\pnh ang {\pntxta .}}{\*\pnseclvl 2\pnucltr\pnsta rt1\pnindent720 \pnhang
{\pntxta .}}{\*\pnseclvl 3\pndec\pnstart 1\pnindent720\p nhang {\pntxta .}}{\*\pnseclvl 4\pnlcltr\pnsta rt1\pnindent720 \pnhang {\pntxta )}}{\*\pnseclvl 5\pndec\pnstart 1\pnindent720\p nhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl 6\pnlcltr\pnsta rt1\pnindent720 \pnhang
{\pntxtb (}{\pntxta )}}{\*\pnseclvl 7\pnlcrm\pnstar t1\pnindent720\ pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl 8\pnlcltr\pnsta rt1\pnindent720 \pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl 9\pnlcrm\pnstar t1\pnindent720\ pnhang {\pntxtb (}{\pntxta )}}\pard\plain
\ql \li0\ri0\widctl par\aspalpha\as pnum\faauto\adj ustright\rin0\l in0\itap0 \fs24\lang1033\ langfe1033\cgri d\langnp1033\la ngfenp1033 {\field\fldedit {\*\fldinst {\cs15\i\f36\fs 14\cf1\insrsid2 20190 MACROBUTTON QueryVeld 01-11-2000 }}{\fldrslt }}{
\insrsid220190
\par
\par }}
the bold letter filed code remains and it is treated as field, so we need to remove the field code and just keep the column name only. how can i do that.Comment
-
I am posting some code to better explain what I told you.
It looks for QueryVeld keyword and replace the following string with pippopippopippo pippopippopippo pippopippopippo pippo (long enough I hope).
Of course it should be improved , for example if string to find is not present , your output is an exact copy of your input.
Ciao
'--------------------------------------------------VB code----------------------------
Private Sub CommandButton1_ Click()
Const ForReading = 1
Dim fs, f, count, cend, myLine ' string count/end,line buffer for file reading
Dim fs1, f1
Set fs = CreateObject("S cripting.FileSy stemObject")
Set f = fs.OpenTextFile ("\New\Input.rt f", ForReading, TristateFalse)
Set fs1 = CreateObject("S cripting.FileSy stemObject")
Set f1 = fs1.CreateTextF ile("\New\Outpu t.rtf", True)
Dim Sfind 'string to find
Dim SReplace ' String to replace
Sfind = "QueryVeld"
SReplace = "pippopippopipp opippopippopipp opippopippopipp opippo"
Do
myLine = f.Readline
count = InStr(1, myLine, Sfind, 1)
If count = 0 Then f1.WriteLine myLine ' exact copy of input , SFind not present in myLine
While count <> 0
MsgBox count
f1.Write Mid(myLine, 1, count + Len(Sfind))
cend = InStr(count + Len(Sfind) + 1, myLine, " ", 1)
f1.Write SReplace
f1.Write Mid(myLine, cend, Len(myLine))
'MsgBox Mid(myLine, count, cend - count)
count = InStr(count + Len(Sfind), myLine, Sfind, 1)
Wend
Loop Until myLine = "\par }}" ' buffer which ends the loop
f1.Close
End Sub
Originally posted by diSangroHello... I think you should read the rtf as text file , search for your keyword, then you can replace it. Of course you need an output file for writing.
Have you already tried this kind of approach ?
Bye,
diSangroComment
-
The code supplied by u distorts the original format of the table. Also u've read the document up to "\\par" but i want to read the doc upto the end which consists of lot of field value to be replaced. And the original format of the table should remain same.
Can this be possible that i'll open the doc thru word object but delete the field code and remain the text as unchanged so that i can easily replace the text with its value. I want to know how can i delete the field codes thru word.
Thanking YouComment
-
"\\par" ?
Loop termination occurs with "\par }}" Which is the text ending your file, while "\\par" never occurs.
Can you post your input file having tables and field codes to replace(I mean... as text)?
Bye
Originally posted by amitpThe code supplied by u distorts the original format of the table. Also u've read the document up to "\\par" but i want to read the doc upto the end which consists of lot of field value to be replaced. And the original format of the table should remain same.
Can this be possible that i'll open the doc thru word object but delete the field code and remain the text as unchanged so that i can easily replace the text with its value. I want to know how can i delete the field codes thru word.
Thanking YouComment
-
yes i'm sending my RTF file.
{\rtf1\ansi \deff4\deflang1 033{\fonttbl{\f 4\froman\fchars et0\fprq2 Times New Roman;}{\f5\fsw iss\fcharset0\f prq2 Arial;}{\f70\fs wiss\fcharset0\ fprq2 KPN Sans{\*\falt Arial};}}{\colo rtbl;\red0\gree n0\blue0;\red0\ green0\blue255;
\red0\green255\ blue255;\red0\g reen255\blue0;\ red255\green0\b lue255;\red255\ green0\blue0;\r ed255\green255\ blue0;\red255\g reen255\blue255 ;\red0\green0\b lue128;\red0\gr een128\blue128; \red0\green128\ blue0;\red128\g reen0\blue128;\ red128\green0\b lue0;
\red128\green12 8\blue0;\red128 \green128\blue1 28;\red192\gree n192\blue192;}{ \stylesheet{\no widctlpar \f4\fs20\lang20 57 \snext0 Normal;}{\s1\sb 240\sa60\keepn\ nowidctlpar \b\f5\fs28\lang 2057\kerning28 \sbasedon0\snex t0 heading 1;}{
\s2\sb240\sa60\ keepn\nowidctlp ar \b\i\f5\lang205 7 \sbasedon0\snex t0 heading 2;}{\*\cs10 \additive Default Paragraph Font;}{\s15\now idctlpar\tqc\tx 4536\tqr\tx9072 \f4\fs20\lang20 57 \sbasedon0\snex t15 header;}{\*\cs1 6 \additive\f5\fs 16 \sbasedon10
CellTitel;}{\*\ cs17 \additive\fs22 \sbasedon16 CellTitelGroot; }{\s18\nowidctl par\tqc\tx4536\ tqr\tx9072 \f4\fs20\lang20 57 \sbasedon0\snex t18 footer;}{\s19\s b120\sa120\nowi dctlpar \b\f4\fs20\lang 2057 \sbasedon0\snex t0 caption;}}{\inf o{\title Klantgegevens}
{\author T-Werkplek}{\oper ator T-Werkplek}{\crea tim\yr1998\mo6\ dy10\hr14\min36 }{\revtim\yr200 2\mo9\dy19\hr11 \min22}{\printi m\yr1997\mo3\dy 11\hr14\min10}{ \version2}{\edm ins0}{\nofpages 1}{\nofwords126 }{\nofchars720} {\*\company PTT Telecom I&AT}{\vern5739 5}}
\paperw11907\pa perh16840\margl 510\margr510\ma rgt431\margb431 \widowctrl\ftnb j\aenddoc\hyphh otz425\hyphcaps 0\formshade \fet0\sectd \psz9\linex0\he adery284\footer y369\colsx709\e ndnhere {\*\pnseclvl1\p nucrm\pnstart1\ pnindent720\pnh ang{\pntxta .}}
{\*\pnseclvl2\p nucltr\pnstart1 \pnindent720\pn hang{\pntxta .}}{\*\pnseclvl 3\pndec\pnstart 1\pnindent720\p nhang{\pntxta .}}{\*\pnseclvl 4\pnlcltr\pnsta rt1\pnindent720 \pnhang{\pntxta )}}{\*\pnseclvl 5\pndec\pnstart 1\pnindent720\p nhang{\pntxtb (}{\pntxta )}}
{\*\pnseclvl6\p nlcltr\pnstart1 \pnindent720\pn hang{\pntxtb (}{\pntxta )}}{\*\pnseclvl 7\pnlcrm\pnstar t1\pnindent720\ pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl 8\pnlcltr\pnsta rt1\pnindent720 \pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl 9
\pnlcrm\pnstart 1\pnindent720\p nhang{\pntxtb (}{\pntxta )}}\trowd \trgaph56\trlef t-56 \clbrdrt\brdrs\ brdrw15 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15 \clbrdrb\brdrs\ brdrw15 \cellx6036\clbr drt\brdrs\brdrw 15 \cellx6283\clbr drt\brdrs\brdrw 15 \clbrdrb
\brdrs\brdrw15 \cellx11143 \pard\plain \keepn\widctlpa r\intbl \f4\fs20\lang20 57 {\cs16\b\f70\fs 16\lang19 Klantgegevens\c ell }{\cs16\f70\fs1 4\lang19 Naam en voorletters of bedrijfsnaam contractant
\par }{\field\flddirty {\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_naam>> }}{\fldrslt }}{\cs16\f70\fs1 4\lang19 \cell \cell Naam en voorletters of bedrijfsnaam gebruiker
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_naam_gebr >> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\b\f70\la ng19 \row }\trowd \trgaph56\trlef t-56 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15 \clbrdrb
\brdrs\brdrw15 \cellx6036\cell x6283\clbrdrt\b rdrs\brdrw15 \clbrdrb\brdrs\ brdrw15 \cellx11143 \pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19 Adres}{\cs16\i\ f70\fs14\lang19
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_adres>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Aansluitadres
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_aansluitadr es>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19
Postcode en woonplaats
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_pc_wpl>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Postcode en woonplaats
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_pc_wpl_gebr >> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\trowd \trgaph56\trlef t-56 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15 \clbrdrb
\brdrs\brdrw15 \cellx6036\cell x6283\clbrdrt\b rdrs\brdrw15 \clbrdrb\brdrs\ brdrw15 \cellx8484\clbr drt\brdrs\brdrw 15 \clbrdrb\brdrs\ brdrw15 \cellx11143 \pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19 Land
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_land_zip> > }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Land
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_land_zip_ge br>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\trowd \trgaph56\trlef t-56 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15
\clbrdrb\brdrs\ brdrw15 \cellx3925\cell x6036\cellx6283 \clbrdrt\brdrs\ brdrw15 \clbrdrb\brdrs\ brdrw15 \cellx8484\clbr drt\brdrs\brdrw 15 \clbrdrb\brdrs\ brdrw15 \cellx11143 \pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19
Contactpersoon
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_cp>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell Telefoonnummer
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_tel>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Contactpersoon
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_cp_gebr>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell Telefoonnummer
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_tel_gebr> > }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\trowd \trgaph56\trlef t-56 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15 \cellx6036
\cellx6283\clbr drt\brdrs\brdrw 15 \cellx11143 \pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19 Inschr.nr. KVK
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_nr_kvk>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Nieuw adres bij verhuizing
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_adres_verh> > }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\pard \nowidctlpar
\par }
The bold letter are the filed codes which remain in the RTF file after the replacement of "<<s_naam>> " like fields with their respective values (For which i was using Word object Find and Replacement method) . So there are number of field codes but i've highlighted only one. If i'll be able to remove the highlighted one from the file then the replaced value will be treated as plain text and will be wrapped if the text lenght is greater than the cell length. I want the table format to be remain as before.
Also if there are any way to remove the field code without reading the file in text mode i.e opening the file thru WORD which i was previously using.
Thanking YouComment
-
'So if I am correct you want to replace field codes with long (normal text) names 'cause they don't fit your tables... and you want to use Word objects.
'Remember the FindReplace Sub I posted some time ago ?
'After:
Set wrdDoc = wrdApp.Document s.Open(Inputfil e)
'Put the line:
Sfind = "^dMACROBUT TON QueryVeld " & Sfind
'And see what happens!
'Does it help?
' diSangro
Originally posted by amitpyes i'm sending my RTF file.
{\rtf1\ansi \deff4\deflang1 033{\fonttbl{\f 4\froman\fchars et0\fprq2 Times New Roman;}{\f5\fsw iss\fcharset0\f prq2 Arial;}{\f70\fs wiss\fcharset0\ fprq2 KPN Sans{\*\falt Arial};}}{\colo rtbl;\red0\gree n0\blue0;\red0\ green0\blue255;
\red0\green255\ blue255;\red0\g reen255\blue0;\ red255\green0\b lue255;\red255\ green0\blue0;\r ed255\green255\ blue0;\red255\g reen255\blue255 ;\red0\green0\b lue128;\red0\gr een128\blue128; \red0\green128\ blue0;\red128\g reen0\blue128;\ red128\green0\b lue0;
\red128\green12 8\blue0;\red128 \green128\blue1 28;\red192\gree n192\blue192;}{ \stylesheet{\no widctlpar \f4\fs20\lang20 57 \snext0 Normal;}{\s1\sb 240\sa60\keepn\ nowidctlpar \b\f5\fs28\lang 2057\kerning28 \sbasedon0\snex t0 heading 1;}{
\s2\sb240\sa60\ keepn\nowidctlp ar \b\i\f5\lang205 7 \sbasedon0\snex t0 heading 2;}{\*\cs10 \additive Default Paragraph Font;}{\s15\now idctlpar\tqc\tx 4536\tqr\tx9072 \f4\fs20\lang20 57 \sbasedon0\snex t15 header;}{\*\cs1 6 \additive\f5\fs 16 \sbasedon10
CellTitel;}{\*\ cs17 \additive\fs22 \sbasedon16 CellTitelGroot; }{\s18\nowidctl par\tqc\tx4536\ tqr\tx9072 \f4\fs20\lang20 57 \sbasedon0\snex t18 footer;}{\s19\s b120\sa120\nowi dctlpar \b\f4\fs20\lang 2057 \sbasedon0\snex t0 caption;}}{\inf o{\title Klantgegevens}
{\author T-Werkplek}{\oper ator T-Werkplek}{\crea tim\yr1998\mo6\ dy10\hr14\min36 }{\revtim\yr200 2\mo9\dy19\hr11 \min22}{\printi m\yr1997\mo3\dy 11\hr14\min10}{ \version2}{\edm ins0}{\nofpages 1}{\nofwords126 }{\nofchars720} {\*\company PTT Telecom I&AT}{\vern5739 5}}
\paperw11907\pa perh16840\margl 510\margr510\ma rgt431\margb431 \widowctrl\ftnb j\aenddoc\hyphh otz425\hyphcaps 0\formshade \fet0\sectd \psz9\linex0\he adery284\footer y369\colsx709\e ndnhere {\*\pnseclvl1\p nucrm\pnstart1\ pnindent720\pnh ang{\pntxta .}}
{\*\pnseclvl2\p nucltr\pnstart1 \pnindent720\pn hang{\pntxta .}}{\*\pnseclvl 3\pndec\pnstart 1\pnindent720\p nhang{\pntxta .}}{\*\pnseclvl 4\pnlcltr\pnsta rt1\pnindent720 \pnhang{\pntxta )}}{\*\pnseclvl 5\pndec\pnstart 1\pnindent720\p nhang{\pntxtb (}{\pntxta )}}
{\*\pnseclvl6\p nlcltr\pnstart1 \pnindent720\pn hang{\pntxtb (}{\pntxta )}}{\*\pnseclvl 7\pnlcrm\pnstar t1\pnindent720\ pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl 8\pnlcltr\pnsta rt1\pnindent720 \pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl 9
\pnlcrm\pnstart 1\pnindent720\p nhang{\pntxtb (}{\pntxta )}}\trowd \trgaph56\trlef t-56 \clbrdrt\brdrs\ brdrw15 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15 \clbrdrb\brdrs\ brdrw15 \cellx6036\clbr drt\brdrs\brdrw 15 \cellx6283\clbr drt\brdrs\brdrw 15 \clbrdrb
\brdrs\brdrw15 \cellx11143 \pard\plain \keepn\widctlpa r\intbl \f4\fs20\lang20 57 {\cs16\b\f70\fs 16\lang19 Klantgegevens\c ell }{\cs16\f70\fs1 4\lang19 Naam en voorletters of bedrijfsnaam contractant
\par }{\field\flddirty {\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_naam>> }}{\fldrslt }}{\cs16\f70\fs1 4\lang19 \cell \cell Naam en voorletters of bedrijfsnaam gebruiker
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_naam_gebr >> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\b\f70\la ng19 \row }\trowd \trgaph56\trlef t-56 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15 \clbrdrb
\brdrs\brdrw15 \cellx6036\cell x6283\clbrdrt\b rdrs\brdrw15 \clbrdrb\brdrs\ brdrw15 \cellx11143 \pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19 Adres}{\cs16\i\ f70\fs14\lang19
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_adres>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Aansluitadres
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_aansluitadr es>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19
Postcode en woonplaats
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_pc_wpl>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Postcode en woonplaats
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_pc_wpl_gebr >> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\trowd \trgaph56\trlef t-56 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15 \clbrdrb
\brdrs\brdrw15 \cellx6036\cell x6283\clbrdrt\b rdrs\brdrw15 \clbrdrb\brdrs\ brdrw15 \cellx8484\clbr drt\brdrs\brdrw 15 \clbrdrb\brdrs\ brdrw15 \cellx11143 \pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19 Land
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_land_zip> > }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Land
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_land_zip_ge br>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\trowd \trgaph56\trlef t-56 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15
\clbrdrb\brdrs\ brdrw15 \cellx3925\cell x6036\cellx6283 \clbrdrt\brdrs\ brdrw15 \clbrdrb\brdrs\ brdrw15 \cellx8484\clbr drt\brdrs\brdrw 15 \clbrdrb\brdrs\ brdrw15 \cellx11143 \pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19
Contactpersoon
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_cp>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell Telefoonnummer
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_tel>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Contactpersoon
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_cp_gebr>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell Telefoonnummer
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_tel_gebr> > }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\trowd \trgaph56\trlef t-56 \clshdng2000 \cellx1362\clbr drt\brdrs\brdrw 15 \cellx6036
\cellx6283\clbr drt\brdrs\brdrw 15 \cellx11143 \pard \keepn\widctlpa r\intbl {\cs16\b\f70\la ng19 \cell }{\cs16\f70\fs1 4\lang19 Inschr.nr. KVK
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_nr_kvk>> }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell \cell Nieuw adres bij verhuizing
\par }{\field\flddir ty{\*\fldinst {\i\f70\fs14 MACROBUTTON QueryVeld <<s_adres_verh> > }}{\fldrslt }}{\cs16\f70\fs 14\lang19 \cell }\pard \widctlpar\intb l {\cs16\f70\lang 19 \row }\pard \nowidctlpar
\par }
The bold letter are the filed codes which remain in the RTF file after the replacement of "<<s_naam>> " like fields with their respective values (For which i was using Word object Find and Replacement method) . So there are number of field codes but i've highlighted only one. If i'll be able to remove the highlighted one from the file then the replaced value will be treated as plain text and will be wrapped if the text lenght is greater than the cell length. I want the table format to be remain as before.
Also if there are any way to remove the field code without reading the file in text mode i.e opening the file thru WORD which i was previously using.
Thanking YouComment
-
According to u i need to read the RTF file as plain text file line by line. Consider 'MyLine ' in which i'm reading a file line by line. If there is a text "<<s_naam>> " present in the line which is another file name. I want to replace "<<s_naam>> " with its whole content. How can i do that. Can this code will be do.
Actually my requirement is that previously my RTF file has only field names which is to be replaced by a value. But now the RTF file consists of field names which are another file names. So i need to replace the field name with the whole content of another file so that the files will be appended. I tried this but in some case it works fine but there comes a blank line between two files and in some case the file becomes corrupt. Need ur help. Thanx in Advance.
Set FsamIn = CreateObject("S cripting.FileSy stemObject")
Set F1In = FsIn.OpenTextFi le(s_naam, ForReading, TristateFalse)
lsWholeFile = F1In.ReadAll
lsMyLine = Replace(lsMyLin e, "<<s_naam>> ", lsWholeFile)Comment
Comment