Why Reading a word document in MS Word 2003 is slow as compared to reading MS Word 2000
Working with files in VB 6.0
Collapse
X
-
I've to append some MS Word 2003 documents to a single document. My word documents contain tables. Each document contains a single table. My code appended the files but there remains some spaces between the tables. Why these spaces comes. I want that the next word document should start at the EOF of immidiate above. I don't know much 'bout WORD 2003 . Could any one suggest me to handle the issue. I'm providing the code.
Dim wrdApp As Word.Applicatio n
Dim wrdDoc As New Word.Document
Dim file1, file2, file3, docName As String
file1 = "C:\Test.rt f"
file2 = "C:\Q0000001.rt f"
file3 = "C:\Q0000002.rt f"
Set wrdApp = CreateObject("W ord.Application ")
wrdApp.Visible = False
Set wrdDoc = wrdApp.Document s.Add(file1)
wrdDoc.Applicat ion.Selection.I nsertFile (file2)
wrdDoc.Applicat ion.Selection.I nsertBreak (WdBreakType.wd LineBreak)
wrdDoc.Applicat ion.Selection.I nsertFile (file3)
wrdDoc.Applicat ion.Selection.I nsertBreak (WdBreakType.wd LineBreak)
wrdDoc.SaveAs (file1)
wrdDoc.CloseComment
-
In addition to my previous query i've one more query. I want to read a Word document which contains some field values. How can i get the field values one by one by reading the document. Below is the content of my word document.
I want to use the word object. Waiting 4 ur reply.
<<klntgeg>> <<lynapinf>> <<apparatuur> > <<infra>> <<totaal>> <<btwdisc>> <<discove>> <<sinfra>> <<CNTKLANT>> <<gidsv>> <<install>> <<betaling>> <<ondertek>>Comment
-
Goete Morgen....Amitp !
try to open your rtf as text file , if you do so a field code is identified by a keyword like MACROBUTTON (Note : length =11 ) etc, followed by the field name (like <<totaal>> )
If you create your rtf having field codes in c:\New\Input.rt f then you can try this vb code:
'---------------------------------------------------------------------------------------------------------------
Private Sub CommandButton2_ Click()
Const ForReading = 1
Dim fs, f, count, cend, myLine ' string count/end,line buffer for file reading
Set fs = CreateObject("S cripting.FileSy stemObject")
Set f = fs.OpenTextFile ("\New\Input.rt f", ForReading, TristateFalse)
Dim Sfind 'string to find
Sfind = "<<"
Do
myLine = f.Readline
count = InStr(1, myLine, Sfind, 1)
While count <> 0
cend = InStr(count, myLine, ">>", 1) + 2
MsgBox Mid(myLine, count, cend - count)
count = InStr(count + Len(Sfind), myLine, Sfind, 1)
Wend
Loop Until Len(myLine) < 11 ' buffer too small ends the loop
End Sub
'-------------------------------------------------------------------------------------------
It will show all the field names in a Msg Box....Exit is when myLine length is < than 11 (less than MACROBUTTON)... ..Does it help?
Bye !
Originally posted by amitpIn addition to my previous query i've one more query. I want to read a Word document which contains some field values. How can i get the field values one by one by reading the document. Below is the content of my word document.
I want to use the word object. Waiting 4 ur reply.
<<klntgeg>> <<lynapinf>> <<apparatuur> > <<infra>> <<totaal>> <<btwdisc>> <<discove>> <<sinfra>> <<CNTKLANT>> <<gidsv>> <<install>> <<betaling>> <<ondertek>>Comment
-
thanks for the ans. but could u help me in this query.
I've to append some MS Word 2003 documents to a single document. My word documents contain tables. Each document contains a single table. My code appended the files but there remains some spaces between the tables. Why these spaces comes. I want that the next word document should start at the EOF of immidiate above. I don't know much 'bout WORD 2003 . Could any one suggest me to handle the issue. I'm providing the code.
Dim wrdApp As Word.Applicatio n
Dim wrdDoc As New Word.Document
Dim file1, file2, file3, docName As String
file1 = "C:\Test.rt f"
file2 = "C:\Q0000001.rt f"
file3 = "C:\Q0000002.rt f"
Set wrdApp = CreateObject("W ord.Application ")
wrdApp.Visible = False
Set wrdDoc = wrdApp.Document s.Add(file1)
wrdDoc.Applicat ion.Selection.I nsertFile (file2)
wrdDoc.Applicat ion.Selection.I nsertFile (file3)
wrdDoc.SaveAs (file1)
wrdDoc.CloseComment
-
As far as you terminate one table a newline char is added ,
that's why you have this problem...can be done but now I'm goin to have lunch!
Bye !
Originally posted by amitpthanks for the ans. but could u help me in this query.
I've to append some MS Word 2003 documents to a single document. My word documents contain tables. Each document contains a single table. My code appended the files but there remains some spaces between the tables. Why these spaces comes. I want that the next word document should start at the EOF of immidiate above. I don't know much 'bout WORD 2003 . Could any one suggest me to handle the issue. I'm providing the code.
Dim wrdApp As Word.Applicatio n
Dim wrdDoc As New Word.Document
Dim file1, file2, file3, docName As String
file1 = "C:\Test.rt f"
file2 = "C:\Q0000001.rt f"
file3 = "C:\Q0000002.rt f"
Set wrdApp = CreateObject("W ord.Application ")
wrdApp.Visible = False
Set wrdDoc = wrdApp.Document s.Add(file1)
wrdDoc.Applicat ion.Selection.I nsertFile (file2)
wrdDoc.Applicat ion.Selection.I nsertFile (file3)
wrdDoc.SaveAs (file1)
wrdDoc.CloseComment
-
...the easiest way would be to open your rtf file in Word , place the cursor at the right end of the table and pres Del ... the new line will be removed and the table will be merged with the second creating the whole table.
Of course if you have ...let's say a hundred tables to merge this is not really practical I know , in this case you need a specific prog which removes newlines.
Is this the case?
Originally posted by amitpDo u hav a solution for the one, then plz send it. Thanking YouComment
-
Originally posted by diSangro...the easiest way would be to open your rtf file in Word , place the cursor at the right end of the table and pres Del ... the new line will be removed and the table will be merged with the second creating the whole table.
Of course if you have ...let's say a hundred tables to merge this is not really practical I know , in this case you need a specific prog which removes newlines.
Is this the case?Comment
-
1> How can i read a doc file line by line there by calculating the total number of lines and identify the blank lines and then deleting the balnk lines from the file. can anybody having any code for this using VB 6.0
2> to replace the field values with text i've used the following code and that works fine for only for texts of max length of 255 characters and beyond that is gives an error Error- 5854 : String Parameter too long. Can any one hav the solution for this.
With wrdRepApp.Selec tion.find
.Text = sFind
.Replacement.Te xt = sReplace
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritic s = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLik e = False
.MatchAllWordFo rms = False
End WithComment
-
Originally posted by amitpCode:... Set wrdDoc = wrdApp.Documents.Add(file1) wrdDoc.Application.Selection.InsertFile (file2) [B]wrdDoc.Application.Selection.InsertBreak (WdBreakType.wdLineBreak)[/B] wrdDoc.Application.Selection.InsertFile (file3) [B]wrdDoc.Application.Selection.InsertBreak (WdBreakType.wdLineBreak)[/B]
Comment
-
Originally posted by amitp2> to replace the field values with text i've used the following code and that works fine for only for texts of max length of 255 characters and beyond that is gives an error Error- 5854 : String Parameter too long. Can any one hav the solution for this.
You can expand on this sort of technique - just use your imagination.Comment
-
i deleted the highlighted lines but the spaces still remains. i happens with the case if the RTF file consists of only a table. That means when the files consisting of tables only appended explicitly a blank line is added. This is not the case with text. So kindly look into this.Comment
-
Originally posted by amitpi deleted the highlighted lines but the spaces still remains. i happens with the case if the RTF file consists of only a table. That means when the files consisting of tables only appended explicitly a blank line is added. This is not the case with text. So kindly look into this.Code:wrdDoc.Application.Selection.TypeBackspace [B]and/or[/B] wrdDoc.Application.Selection.MoveLeft Unit:=wdCharacter, Count:=1
Comment
Comment